2019 Sep 26 3:09 PM
Hi All,
From the Table VBAK I am retrieving KUNNR NETWR and WAERK. The value of WAERK is CHF / EUR / GBP. Some of the clients used more than one currency. For example an individual made purchases 10 different times and 5 of those were in CHF, 2 in EUR and 3 in GBP. I would like to know the procedure of converting the foreign currency into local when more than one currency has been used. If the client made all the purchases in a foreign currency then no conversion is needed.
Thanks in advance.
2019 Sep 27 12:02 PM
Is that what you expect?
SELECT waerk, sum( netwr ) as sum_netwr FROM vbak
WHERE kunnr = my_client
GROUP BY waerk
INTO TABLE @data(vbak_amounts).
IF lines( vbak_amounts ) = 1.
" write amount in TRANSACTION currency
DATA(vbak_amount) = vbak_amounts[ 1 ].
WRITE : / vbak_amount-waerk, vbak_amount-sum_netwr.
ELSE.
" write amount in LOCAL currency
loop at vbak_amounts into vbak_amount.
if vbak_amounts-waerk = local_currency_code.
" No conversion needed
WRITE : / vbak_amount-waerk, vbak_amount-sum_netwr.
else.
" Conversion from WAERK to local currency code
sum_netwr_in_local_currency_code = convert( vbak_amount ).
WRITE : / local_currency_code, sum_netwr_in_local_currency_code.
endif.
endloop.
ENDIF.
2019 Sep 26 3:16 PM
Hi,
Call FMs CONVERT_TO_LOCAL_CURRENCY or CONVERT_TO_FOREIGN_CURRENCY. Here is code and more details:
https://answers.sap.com/questions/6111697/fm-to-convert-amount-from-one-currency-to-another.html
Regards
GK
2019 Sep 27 10:28 AM
Thanks Mr Karkara for your answer. Actually my problem is not regarding conversion (I guess I was not clear). It is about finding out the number of currencies used by the specific client. I brought the issue of conversion because I need to convert them if a client has used more than one currency. But regarding the conversion, I know how to do that.
2019 Sep 27 11:10 AM
Hi Arnab,
In that case, you can look at tables TCURR and TCURC.
Regards
GK
2019 Sep 26 3:21 PM
By using the function module CONVERT_TO_LOCAL_CURRENCY with exchange rate type from VBAK-KURST? (well I don't really know, but you can start searching the forum with those two elements)
2019 Sep 27 10:33 AM
sandra.rossi Thanks for your suggestion. Actually my problem is not regarding conversion (I guess I was not clear). It is about finding out (through coding) the number of currencies used by the specific client. I brought the issue of conversion because I need to convert them if a client has used more than one currency. But regarding the conversion, I know how to do that. Thanks again.
2019 Sep 27 10:37 AM
Hello Arnab Goswami,
Please find the details below:
T-Code for Currency Code: OY03
Table for Currency Code: TCURC
FMs used for Conversion:
a) CONVERT_TO_LOCAL_CURRENCY
b) CONVERT_TO_FOREIGN_CURRENCY
Hope this helps!
Regards
2019 Sep 27 12:02 PM
Is that what you expect?
SELECT waerk, sum( netwr ) as sum_netwr FROM vbak
WHERE kunnr = my_client
GROUP BY waerk
INTO TABLE @data(vbak_amounts).
IF lines( vbak_amounts ) = 1.
" write amount in TRANSACTION currency
DATA(vbak_amount) = vbak_amounts[ 1 ].
WRITE : / vbak_amount-waerk, vbak_amount-sum_netwr.
ELSE.
" write amount in LOCAL currency
loop at vbak_amounts into vbak_amount.
if vbak_amounts-waerk = local_currency_code.
" No conversion needed
WRITE : / vbak_amount-waerk, vbak_amount-sum_netwr.
else.
" Conversion from WAERK to local currency code
sum_netwr_in_local_currency_code = convert( vbak_amount ).
WRITE : / local_currency_code, sum_netwr_in_local_currency_code.
endif.
endloop.
ENDIF.