Conversion of numeric to character field
Hi,
I have an input field in which the user enters a number. This number has to be converted to character and then passed to the function module in my program.
Please let me know which function module I can use to convert this number that the user enters to a charater.
Its a very urgetn requirement.
Thanks & Regards,
Srilakshmi B
hi
use this code . sure you will get it solution.
define one variable with type character and another with numc.
you have to take same length of both variable.
Data : var1(20) type c.
Data : var2(20) type c.
now with help of this statement you can convert data into character.
MOVE var2 to var1.
Regards,
Vipul
Similar Messages
-
How to move the value from a character field to numeric or packed decimal
Hi,
can anyone explain me on how to move the value from a character field to numeric or packed decimal.
Please help me on this. Thanks...
Regards,
Rose.Hi ,
if you use keyword MOVE u may loose the decimal and thoussan separator and if u don't want to loose them just call the FM ..HRCM_STRING_AMOUNT_CONVERT.
i doubt wherther it is HRCM or HCRM just try using *
this will suit ur requirement.
Regards,
KK -
Numeric to character conversion
How to convert the numeric to character format? give me function module.
Hi,
please check out the below program it will help you
REPORT ZSPELL.
TABLES SPELL.
DATA : T_SPELL LIKE SPELL OCCURS 0 WITH HEADER LINE.
DATA : PAMOUNT LIKE SPELL-NUMBER VALUE '1234510'.
SY-TITLE = 'SPELLING NUMBER'.
PERFORM SPELL_AMOUNT USING PAMOUNT 'USD'.
WRITE: 'NUMBERS', T_SPELL-WORD, 'DECIMALS ', T_SPELL-DECWORD.
FORM SPELL_AMOUNT USING PWRBTR PWAERS.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = PAMOUNT
CURRENCY = PWAERS
FILLER = SPACE
LANGUAGE = 'E'
IMPORTING
IN_WORDS = T_SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3.
ENDFORM. " SPELL_AMOUNT
***********please reward points if the information is helpful to you******************* -
Padding character fields with zeros
Hello,
I need to add zeros to the end of character fields TYPE C. I know i can use the conversion routines but that only works for numeric fields.
ThanksThanks for all the replies.
STRLEN will give me the lenght of the field but i need the offset of the last chararcter.
Your post gave me an idea though. I'm doing the following and it's working.
value = 'Thank You '.
tmp = '00000000000000'.
FIND REGEX `\w[ [:space:] ][ [:space:] ]` IN value MATCH OFFSET moff.
IF SY-SUBRC = 0.
OVERLAY value+moff WITH tmp.
ENDIF.
The find looks for the last alphanumeric char and 2 spaces after it meaning the last alphanumeric char in the string.
Thanks to all, i will reward as fairly as possible. -
Concatenating non-character fields
Hi,
I have a nested structure which I am trying to convert into a flat structure so that I can output this to a flat file.
I am trying to concatenate all the fields within my nested structure into a text field but the concatenate command does not automatically convert numerics/quantities.
An extract of my code is as follows:-
loop at itab-rec2 into wa2.
concatenate wa2-ntgew wa2-gewei wa2-volum
wa2-ean11 into text.
tlines-line = text.
append tlines.
clear text.
endloop.
Can anyone advise me on how I can convert the numeric/qty fields into a character string so I can the concatenate all the fields into a string.
Thanks,
RubyHi Ruby,
mybe this could help:
<pre>
data:
lv_separator type c,
lv_offset type syfdpos,
lv_len type sytleng,
lv_chars type tab512.
field-symbols:
<any> type any.
lv_separator = abap_char_utilities=>horizontal_tab.
loop at itab.
do.
assign component sy-index of structure itab to <any>.
if sy-subrc <> 0.
exit."loop
endif.
describe field <any> output length lv_len.
write <any> to lv_chars+lv_offset(lv_len).
add lv_len to lv_offset.
if field separator is needed add these lines
write lv_separator to lv_chars+lv_offset(1).
add 1 to lv_offset.
enddo.
transfer lv_chars to file.
clear lv_chars.
endloop." at itab.
</pre>
This will write a formatted output file but it will use the output formatting options defined for the actual user/language/system. This will determine the representation of numeric and date fields and all other fields with output conversion. That means that in the file you will have what you see on a list or grogram screen, not what you see in debugger. Fields are separated by tabulator. As all fields always are output in the same length, you may omit this part.
Regards,
Clemens -
Gui_upload for csv file with numeric n date fields
Hi ,
i searched on net on how to use GUI_UPLOAD for csv files using split function but the spilt function requires that the data type of all fields of the internal table should be character whereas in my case there is a numeric n data field too.So kindly help me how to do it.
One way ppl might suggest that give all the fields as char in the internal n after recieving the data in the internal convert the required fields back to data n numeric n then finally insert to the database but if i have 80 fields u would really dont want to do that as it requires precision to convert it to the same type n length as in the original database for all the fields.yeah i guess that would be a bit longer if i m having more no of fields (80) compared to ORACLE where this can be done in a shorter way.
SO i shall use 2 internal tables here rite?? i mean first one(with all fields as char) for storing the split function values and the other one (with actual data types) .CAN u plz tell me how to convert or cast from one data type to another n while moving values from 1st internal table to another which way shall i do.
Thanks for ur help n can u suggest if there is any other method for uploading csv also other than this split method n whether this method is better n faster than others.
THANX -
ANY FUNCTION MODULE TO ADD LEADING ZEROS FOR A CHARACTER FIELD
THE CHARACTER FIELD IS OF LENGTH 40 AND IT HAS 5 NON NUMERIC CHARACTERS
Hi ,
Try this
DATA : c4(40).
data : P_FIELD(40) TYPE N.
UNPACK P_FIELD to c40.
<b>Reward Points if useful</b>
Regards
Saket Sharma -
Alphameric value conversion to numeric
Hi all,
Somebody knows how is possible converts an alphameric to a numeric ?
I need to force insertion of any alphameric value into numeric field. This is for insert into partitioned by list table based on mod(field, 8) partition.
I guess there is a way.....but I don't know how !
thank you !As the outer operation (mod) is not reversible (if mod(x,8)=1, then what was x?), there is no way that the whole thing is reversible.
Besides, I don't know what the maximum length of your character field is, because the code does leave room for some strange behaviour:
SQL> exec :string := 'jsdfklfjsdklfjasdfkl;sjdflk;asdjfklsdfjasldk;f';
SQL> select mod(replace(SUBSTR(DUMP(:STRING),INSTR(DUMP(:STRING),':')+1),','),8) from dual;
select mod(replace(SUBSTR(DUMP(:STRING),INSTR(DUMP(:STRING),':')+1),','),8) from dual
ERROR at line 1:
ORA-01426: numeric overflowOk, that was to be expected given the length of the string. But this?
SQL> exec :string := 'jsdfklfjsdklfjasd';
SQL> select mod(replace(SUBSTR(DUMP(:STRING),INSTR(DUMP(:STRING),':')+1),','),8) from dual;
MOD(REPLACE(SUBSTR(DUMP(:STRING),INSTR(DUMP(:STRING),':')+1),','),8)
-3.000E+10The mod function returning a huge negative number?? -
Character Field as Number, Need commas?
I move a quantity to a character field for a form display output. I left justify the character by shift character field left deleting leading spaces. This way it formats perfectly in the column on my report/form.
Is there any easy syntaxfunction module, etc., that will take char field 1000.0 and put inn a comma 1,000.0?
I don't want the value to shift back to the right (right-justify).
Thank-You
Edited by: TMM on Jan 30, 2009 11:30 AMHi,
Ok..Please check this..
* Input character.
DATA: v_input TYPE char20 VALUE '1000.0',
v_output TYPE char20,
v_num TYPE p DECIMALS 1.
* Move it to numeric variable.
v_num = v_input.
* Use the write statement to add the thousands separator.
WRITE v_num TO v_output.
* Make sure in the user settings the decimal notation is 1,234,567.89
* otherwise use this code.
SET COUNTRY 'US'.
WRITE v_num TO v_output.
SET COUNTRY space.
* Remove the leading spaze.
SHIFT v_output LEFT DELETING LEADING space.
* Display
WRITE:/ v_output.
Thanks
Naren -
How to sort a character field with numbers and letters on the end
I have an internal table with character field which has data like this after I sort it. This is not what I expect from the sort.:
13A
15A
29A
30A
31A
33A
123A
125
62
76
94A
I expect this, which is sorted number first, then alpha. Any ideas how to get this sort?:
13A
15A
29A
30A
31A
33A
62
76
94A
123A
125Thanks for the suggestions. After reading the suggestions and reviewing some other post threads, here's what I did to get the sort to work:
Add a dash - to the end of any record that did not have an alphabet character at the end. This way, all records have at least one non-numeric character at the end. Then I overlayed zeros '0000000' over each record. Then I sorted the table. Afterwards, I removed the dashes and zeros.
The long way around, but it worked for me. Since the internal table is processed in memory, it doesn't add much overhead to the run time. -
Check..numeric and charcter fields.
Hi,
iam checking the conditions for numeric and character.if the output is numeric then it can shift to right justify,else if it is charcter left justify.but the following code is not checking for charcter fields.
data:p_input type c.
data: pout type string.
data: htype like DD01V-DATATYPE.
if htype = 'CHAR'.
shift htype LEFT DELETING LEADING space.
else.
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
STRING_IN = P_INPUT
IMPORTING
STRING_OUT = POUT
HTYPE = HTYPE.
SHIFT htype RIGHT DELETING TRAILING space.
endif.
plz help me..
thankshi,
try sth like that:
parameters p_input(50).
DATA: pout TYPE string.
DATA: htype LIKE dd01v-datatype.
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
string_in = p_input
IMPORTING
string_out = pout
htype = htype.
IF htype = 'CHAR'.
SHIFT pout LEFT DELETING LEADING space.
ELSE.
SHIFT pout RIGHT DELETING TRAILING space.
ENDIF.
Andreas -
How can i compare the character fields?
I have a requirement to compare the character fields .
I have to compare the 2 character fields of a table CDPOS
As follows .
If CDPOS-VALUE-OLD GT CDPOS-VALUE-NEW
Populate REDATED = YES.
ELSE
Populate REDATED = NO.
My doubt here is how can we compare the character fields.?
When I do Extended Program Check: I am getting error like this ?
Greater than/less than comparisons with character type operands may not be portable
Please give me idea .
Thanks ,
Suresh Kumar.Hi suresh,
DATA : a TYPE char10 VALUE 'DBCD',
b TYPE char10 VALUE '4234',
c TYPE char10 VALUE '3456',
d TYPE char10 VALUE 'ADA',
e TYPE char10 VALUE '234567'.
IF b GT c. "this case checks for numeric values
WRITE :/ 'B is bigger'.
ELSE.
WRITE :/ 'C is bigger'.
ENDIF.
IF a GT d. "this case checks for alphbetical order
WRITE :/ 'A is bigger'.
ELSE.
WRITE :/ 'D is bigger'.
ENDIF.
IF strlen( a ) GT strlen( d ). "this case checks for no of chars
WRITE :/ 'A is bigger'.
ELSE.
WRITE :/ 'D is bigger'.
ENDIF.
IF a GT c. "this case first alph then numerics
WRITE :/ 'A is bigger'.
ELSE.
WRITE :/ 'D is bigger'.
ENDIF. -
How to get a currency format for a character field
for some specifix reason, we have a requirement to show character field (which results in value 633948) in the format $633,948
how do i do this?
if i do SELECT to_char(:c_1,'$999,999')) from dual;
it gives me ora: 01722: invalid number error
c_1 is a user parameter of data type characterTry using TO_NUMBER first, as in something like:
SQL> VARIABLE c_1 VARCHAR2(6)
SQL> EXECUTE :c_1 := '633948';
PL/SQL procedure successfully completed.
SQL> SELECT TO_CHAR(TO_NUMBER(:c_1), '$999,999') FROM DUAL;
TO_CHAR(T
$633,948Hope this helps. -
Error " conversion error between two character sets" in PI MONI
Hi Experts
I am doing file to Idoc scenario. I am getting the following error in PI MONI "conversion error between two character sets".
please suggest me how to solve the issue.
thanx in advance.Hi Mickael
Below is the complete error message found in PI MONI.
SAP:Error SOAP:mustUnderstand="1" xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SAP:Category>XIServer</SAP:Category>
<SAP:Code area="INTERNAL">SYSTEM_DUMP</SAP:Code>
<SAP:P1 />
<SAP:P2 />
<SAP:P3 />
<SAP:P4 />
<SAP:AdditionalText />
<SAP:Stack>PI Server : XBTO80__0000 : Conversion error between two character sets.</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
</SAP:Error> -
Hi All,
While transferring materials form ECC to GTS (Sandbox), i am receiving the above mentioned error.
Conversion error in module API6850_HDR_PROD_MAP, field API6850_HDR-WEIGHTUNIT_ISO, value LBR.
As per standard , In the ISO code for US pound its mentioned as LBR in both ECC and GTS
But within material master we generally use LB as US pound.
Can anyone please let us know how we can solve this one?
Regards
ProloyHello Proloy,
UoM handling is often issue within material transfer.
You have generally 2 options:
1. In GTS maintain via TA CUNI your LB as is in your feeder. I would suggest to adjust GTS customizing with your ERP. Just do Utilities --> Adjustment and your RFC to feeder.
2. Or you can map your LB to GTS LBR via user exit.
Cheers,
Gabriel.
Maybe you are looking for
-
Hello, Does anyone know how itunes match and home sharing are working together? Basically at home I'm using home sharing. Me and my partner are sharing the music. On our iphones, home sharing is activated with my account as reference. What will happe
-
PNPCE in ABAP Query !!! Slection is not working completely
Hi I have developed an ABAP query using LDB PNPCE. I am reading data from IT000,IT0001 etc . I test the query in QA and I noticed that the PNCPCE screen doesnt care about the selection in query. Like I have given the date range in PNCPE default sc
-
Hi, Oracle database 10g. Oracle Form 10g. I am using webutil to execute this command : Client_host(' CMD /C ipconfig > c:\IPAddress.Txt', No_Screen); But when i run this statment the cmd screen come in front of me. if we can't hide this screen is the
-
Managed properties in display templates
Hi I'm trying to include some custom managed properties (GlossaryProductString) into my custom display template but the ct.CurrentItem.GlossaryProductString is always undefined. What I did: Create managed property and mark it as retrievable Full cra
-
No signal from WRT54G and cannot reconfigure...
Hi, I bought my WRT54G about 6 months ago and it occassionally lost its setup. That is, it would forget the network name and passcode. It has done that again and, when I use the CD to set it up again, it repeatedly asks me for the password. It