The simplest explanation is to follow the rules: Use INTERNAL format for anything involving data type CURR. Use EXTERNAL for all other data types. Use BAPI_CURRENCY_CONV* to convert between them.
The online help explains it fairly well, but for a really detailed explanation grab a cup of coffee (you'll need it) and have a read through note 153707
Hi,
I usually retrieve the decimal places of the currency from tcurx table, and then do some math operations with the amount to convert.
Then I use BAPI BAPI_EXCHANGERATE_GETDETAIL to get the exchange rate details and use that information to do the conversion of the amount.
Example not tested.
data: ls_tcurx type tcurx, lv_to_curr type SYCURR, lv_fr_curr type SyCurr, lv_date type sy-datum, lv_amount type dmbtr, lv_convert type dmbtr, ls_exchrt type bapi1093_0, ls_return type bapiret1. lv_amount = 50. lv_to_curr = 'JPY'. lv_fr_curr = 'USD'. lv_date = sy-datum. select single * from tcurx into ls_tcurx where currkey eq lv_to_curr. if ls_tcurx is not initial. case ls_tcurx-currdec. when 1. lv_amount = lv_amount * 10. when 0. lv_amount = lv_amount * 100. when 3. lv_amount = lv_amount / 10. when others. endcase. endif. call function 'BAPI_EXCHANGERATE_GETDETAIL' exporting rate_type = '1004' " 1004 P&L / '1002' Balance Sheet from_curr = lv_fr_curr to_currncy = lv_to_curr date = '20180329' importing exch_rate = ls_exchrt return = ls_return. lv_convert = lv_amount * ( ( ls_exchrt-exch_rate * ls_exchrt-to_factor ) / ls_exchrt-from_factor ).
Add comment