Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Function module to Convert the amount's decimal point ie Comma to Period

Former Member
0 Kudos

Hi Guru,

I am using a BDC to park the Vendor invoice there I am internally calculating some tax amount in that decimal amounts are shown by period based upon my user profile settings.

So I need a FM to change the amount decimal point seperator to 'Comma(22,99)' to 'Period(22.99)' vice versa based on user profile settings.

Please help me on this

Regards

Paul

8 REPLIES 8

former_member188829
Active Contributor
0 Kudos

Instead FM Use Replace Key word..

Replace '.' with ',' into v_var.

Message was edited by:

Vishnu Reddy

0 Kudos

I need FM only so that it will change in accordance with User profile setting.

Former Member
0 Kudos

Use following code

REPLACE ALL OCCURRENCES OF ',' IN: w_num1 WITH '.'.

former_member386202
Active Contributor
0 Kudos

Hi,

Better to use replace statement

Ex.

DATA: c4(4) TYPE C.

c4 = '12,345'.

REPLACE ALL OCCURRENCES OF ',' IN c4 WITH '.'

Reward Points

Regards,

Prashant

0 Kudos

Sugest me any FM so that it will change in accordance with User profile setting.

0 Kudos

there is no such FM for it...

you can use REPLACE and develope your own FM to handle the decimal notation change as per user profile

take following code for reference...

FORM f_convert_num CHANGING ch_num.

DATA : w_dcpfm LIKE usr01-dcpfm,

w_num1(30) TYPE c,

w_off TYPE i.

*FIELD_NUM = 1,233.50 OR FIELD_NUM = 1.233,50 OR FIELD_NUM = 1 233,50

****************************************

MOVE ch_num TO w_num1.

SELECT SINGLE dcpfm

FROM usr01

INTO w_dcpfm

WHERE bname EQ sy-uname.

IF sy-subrc EQ c_zero.

ENDIF.

IF w_dcpfm EQ c_checked.

REPLACE ALL OCCURRENCES OF c_comma IN: w_num1 WITH c_blank.

ELSEIF w_dcpfm EQ c_blank.

REPLACE ALL OCCURENCES OF c_dot IN: w_num1 WITH c_hash.

REPLACE ALL OCCURENCES OF c_comma IN: w_num1 WITH c_dot.

REPLACE ALL OCCURENCES OF c_hash IN: w_num1 WITH c_comma.

REPLACE ALL OCCURRENCES OF c_comma IN: w_num1 WITH c_blank.

ELSEIF w_dcpfm EQ c_yes.

TRANSLATE w_num1 USING c_commadot.

CONDENSE w_num1.

TRANSLATE w_num1 USING c_spacecomma.

FIND c_dcomma IN w_num1 MATCH OFFSET w_off.

w_off = 30 - w_off.

SHIFT w_num1 BY w_off PLACES RIGHT.

REPLACE ALL OCCURRENCES OF c_comma IN: w_num1 WITH c_blank.

ENDIF. "End of w_dcpfm check

CONDENSE w_num1.

MOVE w_num1 TO ch_num.

ENDFORM. " f_convert_num

0 Kudos

Hi Sharayu,

I saw this your function, it's useful for me, now I met with difficulties this problem. But it also have some error at c_zero,c_check ... What is it !? Pls help me ... Thanks for all help.

0 Kudos

all the c_ fields are constants...

e.g.

c_space = ' '

c_check = 'X'

c_yes = 'Y'

just replace all the constants with the symbol literals that name signifies