2023 May 17 8:22 AM
Hi Experts!
in WRBTR field come out values with different currency which as u can see it's separated. is there a way to make the value with USD convert it to IDR so it can be summarized ?
Thank you.
2023 May 17 9:03 AM
demaauliansyah
Yes, it is possible to convert the WRBTR field values with different currency to IDR. You can use the function CURRENCY_CONVERSION
which performs a currency conversion for the value passed to the formal parameter amount. The result has the data type CURR with the same technical attributes as the actual parameter passed to amount. The value passed is rounded to two decimal places before it is converted1.
Here is an example code snippet that you can use:
DATA: l_wrbtr TYPE wrbtr,
l_idr TYPE wrbtr.
l_wrbtr = 1000.00.
CALL FUNCTION 'CURRENCY_CONVERSION'
EXPORTING
amount = l_wrbtr
source_currency = 'USD'
target_currency = 'IDR'
IMPORTING
converted_amount = l_idr.
CopyI hope this helps! Let me know if you have any other questions.
2023 May 17 10:15 AM
2023 May 23 9:08 AM
simply put, you need to change the data in your itab and convert them into the currency you wanted ( in this case USD -> IDR ) using function module such as above ( providing the import export parameter), or coding the conversion logic by yourself.
2023 May 23 10:14 AM
I think the new SQL (or via CDS) allow currency conversion. But if your system doesn't, or you don't know how to call those things, or you don't want to (or cannot to), then, before the ALV calling thing, convert your field to IDR (as yogananda.muthaiah suggested).
You can do with something like:
loop at itab assigning field-symbol(<line>).
<line>-wrtbr = your_class=>convert_to_idr( <line>-wrtbr ). "if you are using a local class, you can PERFORM CHANGING it
endloop.