Application Development and Automation 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: 
Read only

Amount Conversion

Former Member
0 Likes
2,429

hi all,

I am using BAPI_AR_ACC_GETOPENITEMS to get open items. The amount length in the bapi is (23,4). I need to convert to normal format (13,2).

If I am directly assigning the values are gettting changed

Ex:If the amount from BAPI is 12.4500

when i am assigning the value is changed to 1245.00

Can some one please help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,228

Hi Aravind,

You can use the FM BKK_AMOUNT_CONV_TO_EXTERNAL.

Based on the currency it will give you the decimals.

It will also provide rounding functionality.

e.g. if the amount is 12345.12782 and currency is INR then it will provide you the value 12345.13

Regards,

Raju.

11 REPLIES 11
Read only

Former Member
0 Likes
2,228

get it to charcter format.

shift left deleting trailing spaces

move to trarget varaible.

Read only

Former Member
0 Likes
2,228

Hi,

create two variables with CHAR type and use the command SPLIT v_amt at ' . 'and store into separately.

Then Concatenate v_char1 v_char2(2) into v_char3.

Then assign to (13,2) variable.

Regards,

Sunil

Read only

vinod_vemuru2
Active Contributor
0 Likes
2,228

HI Arvind,

This is because ur BAPI parameter has 4 decimals and ur variable has 2 decimals. Assignment happens from right to left. Try by using currency with WRITE TO statement. Not sure if it solves ur problem.

If doesn't work, then try to check for some FM which does this conversion.

Thanks,

Vinod.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,228

Hello Aravind,

Can you share your code as to how you are "directly assigning the values" to a variable of type (13,2) ?

I think the most correct statment for this will be:

WRITE <source_amt> TO <target_amt> CURRENCY <target_curr>

Hope this helps.

BR,

Suhas

Read only

Former Member
0 Likes
2,228

I am assigning in this way...

l_dmbtr = t_openitems-lc_amount.

here t_openitems is the internal table which contains the extract from bapi.

lc_amount is amount field in BAPI.

Read only

0 Likes
2,228

l_dmbtr = t_openitems-lc_amount.

l_dmbtr = l_dmbtr * 10.... to move decimal to right

l_dmbtr = ( l_dmbtr / 10 ).... to move the decimal left

try dividing or multiplying the value l_dmbtr as per your requirement..

Read only

0 Likes
2,228

Hi,

Try this.

DATA: gw_numeric(14) TYPE n, "To store Numeric Value

data: v_var(14) type c value '3333'.

COnstants: c_amtmask14(14) TYPE c VALUE '___________.__',

WRITE V_var TO gw_numeric USING EDIT MASK c_amtmask14.

Regards,

Peranandam

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,228

Hello,

Instead of :

l_dmbtr = t_openitems-lc_amount.

Can you try:

WRITE t_openitems-lc_amount TO l_dmbtr CURRENCY t_openitems-loc_currcy

Hope this helps.

BR,

Suhas

Read only

Former Member
0 Likes
2,228

when you are displaying divide amount by100

Read only

Former Member
0 Likes
2,229

Hi Aravind,

You can use the FM BKK_AMOUNT_CONV_TO_EXTERNAL.

Based on the currency it will give you the decimals.

It will also provide rounding functionality.

e.g. if the amount is 12345.12782 and currency is INR then it will provide you the value 12345.13

Regards,

Raju.

Read only

0 Likes
2,228

hi all,

Thanks a lot for your replies.

The FM BKK_AMOUNT_CONV_TO_EXTERNAL solved my problem.

Aravind