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

conversion internal to external

Gaku
Explorer
0 Likes
7,897

Hello.

I want to display 123,456yen.

However, the following program display 12,345,600.

Please tell me the mistake I made.

Also, please tell me when I use the following BAPI and currency.

DATA:gv_num1 TYPE p DECIMALS 2 VALUE '1234.56',

gv_num2 TYPE bseg-mwsts.

CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL'
EXPORTING
currency = 'JPY'
amount_internal = gv_num1
IMPORTING
amount_external = gv_num2.

WRITE: gv_num2 CURRENCY 'JPY'.

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
7,142

You must never WRITE external format. WRITE a data object in internal format and it will render the content by automatically converting it to the external format. So, if you don't call BAPI_CURRENCY_CONV_TO_EXTERNAL, it will write 123456 as expected.

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
7,143

You must never WRITE external format. WRITE a data object in internal format and it will render the content by automatically converting it to the external format. So, if you don't call BAPI_CURRENCY_CONV_TO_EXTERNAL, it will write 123456 as expected.

Read only

touzik_itc
Active Participant
7,142
CONSTANTS: c_value2 TYPE p LENGTH 10 DECIMALS 2 VALUE '1234.56',
c_value3 TYPE p LENGTH 10 DECIMALS 3 VALUE '1234.56',
c_value4 TYPE p LENGTH 10 DECIMALS 4 VALUE '1234.56'.
WRITE / |Original value with 2 decimal places: { c_value2 }, value as a currency without decimal palces: { c_value2 CURRENCY = 'JPY' }Yen|.
WRITE / |Original value with 3 decimal places: { c_value3 }, value as a currency without decimal palces: { c_value3 CURRENCY = 'JPY' }Yen|.
WRITE / |Original value with 4 decimal places: { c_value4 }, value as a currency without decimal palces: { c_value4 CURRENCY = 'JPY' }Yen|.

All decimal places are converted to pre-decimal places, use appropriate data type:

Original value with 2 decimal places: 1234.56, value as a currency without decimal palces: 123456Yen
Original value with 3 decimal places: 1234.560, value as a currency without decimal palces: 1234560Yen
Original value with 4 decimal places: 1234.5600, value as a currency without decimal palces: 12345600Yen