02-08-2012 7:08 AM
Hi,
I am using this to convert a JPY currency, there is no decimal for this currency.
currency_key = 'JPY'.
write XXX TO YYY currency currency_key.
The statement do not convert the amount correctly, for example,
when XXX = 100.00
YYY will turn into 10,000 which is not correct.
the "write" command will always remove the decimal point of 100.00 and turn it into 10000 for JPY currency.
Is there any other better way to perform the conversion?
Thank you.
02-08-2012 7:19 AM
when XXX = 100.00
YYY will turn into 10,000 which is not correct.
I think this is correct. Internally SAP stores amounts in DECIMAL 2 format & based on the currency the amounts are formatted accordingly.
Why do you say this conversion is not correct?
BR,
Suhas
02-08-2012 7:22 AM
XXX is declared to have 2 decimal places.
When user put JPY amount, let say JPY 100, the internal variable XXX will store it as 100.00.
After the "write" statement, the amount become JPY10000.
02-08-2012 7:42 AM
Hi,
Write statement using value in table TCURX for decimal conversion.
TCURX has two fields - currkey and currdec.
you can put currkey = JPY
and check what is the value of CURRDEC (number of decimal places). Most probably it will be 0.
That is why it is changing it to 10000. SO it is correct.
regards,
Harsh Bansal
02-08-2012 7:55 AM
REPORT Y_TEST_JPY.
data: y_jpy LIKE BSEG-WRBTR.
data: curr LIKE BKPF-WAERS.
data: y_jpy2(16) TYPE c.
y_jpy = 100.
curr = 'JPY'.
write y_jpy to y_jpy2 currency curr.
write: / y_jpy2.
see the example above, my amount is Japanese Yen 100. but this report will return Japanese Yen 10000.
100 Yen is not equal to 10000 Yen.
02-08-2012 8:56 AM
Hi,
Please check the comment above by me. It explains the functionality of write statement.
Regards,
Harsh Bansal
02-08-2012 12:32 PM
In your example, you fill 100 internally (no conversion takes place), which becomes 100.00 in the database and is converted to an external 10000 Yen by the WRITE statement. System behaves as expected (by the rest of us, at least).
You would need to enter "100" externally e.g. into a screen amount field bound to a currency field containing JPY, then it will be converted to 1.00 in the database and back to 100 Yen for display.
Don't mix up internal/external format during input and output.
Thomas
02-08-2012 7:43 AM
Hi,
Use Function module 'CONVERT_CURRENCY_BY_RATE' .
I think this would give correct result.
Regards,
Supriya.