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

How many currencies did a specific client used?

former_member623629
Participant
0 Kudos
1,053

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.

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
944

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.
7 REPLIES 7
Read only

GK817
Active Contributor
0 Kudos
944

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

Read only

0 Kudos
944

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.

Read only

GK817
Active Contributor
0 Kudos
944

Hi Arnab,

In that case, you can look at tables TCURR and TCURC.

Regards

GK

Read only

Sandra_Rossi
Active Contributor
944

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)

Read only

former_member623629
Participant
0 Kudos
944

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.

Read only

former_member1716
Active Contributor
0 Kudos
944

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

Read only

Sandra_Rossi
Active Contributor
945

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.