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

Currency conversion issue, any solution for this?

Former Member
0 Likes
1,011

Hi Experts,

I have input data from Excel file, every number is pure number without format.

After uploading the file to an internal table, I assign it to a variable with data type CURR 13 with 2 decimal places.

The problem is:

20 USD in excel file will become 20.00 USD in SAP which is correct BUT

20000 VND in excel file will become 20000.00 VND

and when I saved this value to the database and view it on screen it becomes: 2,000,000 VND which is not correct. I see it 100 times than the original value.

Can any body explain to me why? and how do I fix this?

Thanks,

Anthony

5 REPLIES 5
Read only

mvoros
Active Contributor
0 Likes
807

Hi,

do you use fixed point arithmetic in your program? To check this display program attributes in SE38.

Cheers

Read only

Former Member
0 Likes
807

Hi ,

Use the below logic Instead of DMBTR use your Amount field.

SELECT SINGLE * FROM t001 INTO l_t0011 WHERE bukrs = <fs_original>-bukrs.

SELECT SINGLE * FROM tcurx INTO l_curr

WHERE currkey = l_t0011-waers.

IF sy-subrc EQ 0 .

v_con = 100.

DO l_curr-currdec TIMES.

v_con = v_con / 10.

ENDDO.

Rgds,

Arun

<fs_reposted>-dmbtr = <fs_reposted>-dmbtr * v_con.

ENDIF.

Read only

Former Member
0 Likes
807

hi anthony,

can you try this one?

before assigning the value to the variable with the data type of currency,

just use WRITE TO with the CURRENCY 'USD'.

rgds,

guna..

Read only

Former Member
0 Likes
807

Hi Anthony,

I think you should do a conversion step for currency amount before insert them to DB. Please try FM:

BAPI_CURRENCY_CONV_TO_INTERNAL

for each currency code and currency amount.

Hope that helps.

Thien

Read only

0 Likes
807

Thank you all for your help!

Actually I use the FM

 CURRENCY_CONVERTING_FACTOR

and I calculate the actual amount by doing:

lv_amount = lv_amount / factor "return from the above FM 

It works.