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: 

write XXX TO YYY currency currency_key. JPY currency problem.

Former Member
0 Kudos

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.

7 REPLIES 7

SuhaSaha
Advisor
Advisor
0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

Hi,

Please check the comment above by me. It explains the functionality of write statement.

Regards,

Harsh Bansal

0 Kudos

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

Former Member
0 Kudos

Hi,

Use Function module 'CONVERT_CURRENCY_BY_RATE' .

I think this would give correct result.

Regards,

Supriya.