07-14-2009 12:23 PM
Hi,
I need to convert any number to format XXX.XXX.XXX,XX
For Eg. Number is 123456.00
expected 123.456,00
Please let me know any Function module used for this.
This is has to be moved to character field and then displayed so directly assigning to data element like KEBTR wont help.
Regards,
Shraddha
07-14-2009 12:56 PM
Normally with displaying decimal values, the decimal display is taken from your user settings.
Perhaps change it over there so you get the desired output format?
07-14-2009 12:28 PM
Hi Shraddha,
WRITE 😕 lv_data USING EDIT MASK
' ___.___.___,__'.
Move lv_data to l_field.
Thanks,
Best regards,
Prashant
07-14-2009 12:37 PM
Hi Prashant,
I cannot use edit mask as we will not be sure of the length of the numer.
What I mean is this number is system calculated amount.
stored in system in format XXXXXX.XX
Eg 127689.50
16796.38
and I need to send this to SAVE_TEXT
So this will be converted into char
Now before passing it to SAVE_TEXT, I need to make it to correct format like 127,689.50
16.796,38
Hop this makes it clearer.
07-14-2009 12:31 PM
Hi,
I guess this might help you....
data:var1(10) tyep c default '123456.00,
var2(3) type c,
var3(15) type c.
split var1 at '.' into var1 var2.
concatenate var10(3) '.' var13(3) ',' var2 into var3.
write: var3.
Pooja
07-14-2009 12:32 PM
hI
There is no function module to convert corrency into XXX.
write logic using SPLIT function.
Regards
Sekhar
07-14-2009 12:37 PM
Check this code snippet.
DATA: num TYPE p DECIMALS 2.
CALL FUNCTION 'HRCM_STRING_TO_AMOUNT_CONVERT'
EXPORTING
string = '123456'
decimal_separator = ','
thousands_separator = '.'
IMPORTING
betrg = num .
IF sy-subrc <> 0.
ENDIF.
WRITE num left-justified.
Thanks
07-14-2009 12:39 PM
Hi Nitesh,
I executed this FM HRCM_STRING_TO_AMOUNT_CONVERT by giving dummy data like 123456 , '.', ',' but it gave me same output whatever I pass. It does not convert the format. Can you please let me know how to execute it?
07-14-2009 12:59 PM
Hi Shraddha,
You could use the following code:
DATA wa_curr TYPE dmbtr value '198765.88'.
DATA wa_curr2(16) TYPE c.
WRITE wa_curr TO wa_curr2.
wa_curr2 will have the amount properly formatted as per User preference... (198,765.88 or 198.765,88)
You could use wa_curr2 in SAVE_TEXT..
Revert if you need more.
07-14-2009 12:37 PM
Hi ,
U hav to use
WRITE <var> USING EDIT MASK 'RR___.___.___,__'.
Amitava
07-14-2009 12:47 PM
y number to format XXX.XXX.XXX,XX
For Eg. Number is 123456.00
expected 123.456,00
data: string1 type string,
string2 type string,
string3 type string.
string1 = 123,456.00.
find all accurences of string1 at ',' into v_line.
if v_line <= 2.
do v_line time.
split string1 at ', ' into string2 string3.
string2 = 123
string3 = 456.
exit.
enddo.
endif.
split string3 at '.' into string1.
now, replace the value with 'X'.
now string1 = .00
string2 = 123.
string3 = 456.
07-14-2009 12:55 PM
Hi Chandra,
I do not mean I want literally number to be printed as XXXXXX
What I need is:
I will get variable numbers
16346.00
238765903.67
456.89
What I need is it should have ' .' as a separator in between.
16346.00 should be 16.346,00
238765903.67 should be 238.765.903,00
456.89 should be 456,00
These values were examples.
We could have any value here
07-14-2009 12:56 PM
Normally with displaying decimal values, the decimal display is taken from your user settings.
Perhaps change it over there so you get the desired output format?
07-14-2009 1:00 PM
Hi Maen,
After changing this value needs to be passed to function module SAVE_TEXT where it would be taken care as a char field. Now char fields are not changed into the desired format.
That is the reason I need to change the format programmatically and then pass is to the FM.
07-14-2009 1:02 PM
Hi Ankesh,
Can you please let me know what shall be the format of variable 2 in this case.
I need to do this. But I am not getting the correct format.
For you reference this is amount field and has to be converted into European format.
07-14-2009 1:08 PM
Hi Shraddha ,
Please see the code below ,
data : num type DMBTR ,
text type char15.
num = '16346.00'.
num = floor( num ).
write num CURRENCY 'USD'..
num = '238765903.67'.
num = floor( num ).
write num CURRENCY 'USD'..
num = '456.89'.
num = floor( num ).
write num to text CURRENCY 'USD'..
write text.
In case you want to write it directly , you can do it else move it to a varaibale as in case3 .
The only thing to check is that the output format will be based on the setting of the currency 'USD' in your system , in case it is not set properly then the display will not be correct.
Regards,
Arun
07-14-2009 1:09 PM
HI Shraddha,
As in my code, the varibale wa_curr2 is TYPE c...
We have to keep it TYPE c to use the WRITE statement.
and also remember to keep the appropriate format in User preference also whosoever is going to execute the program.
07-14-2009 1:27 PM
07-14-2009 1:24 PM
Hi,
You can also check the following Sample Code i think it is working according to your requirements
DATA: amount TYPE p DECIMALS 2,
camount(25).
amount = '2512.24'.
BREAK-POINT.
WRITE: amount TO camount.
CONDENSE: camount.
REPLACE ALL OCCURRENCES OF '.' IN camount WITH '-'.
REPLACE ALL OCCURRENCES OF ',' IN camount WITH '.'.
REPLACE ALL OCCURRENCES OF '-' IN camount WITH ','.
WRITE: camount.
Regards,
Faisal