cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Function module for Currency translation

Former Member
0 Likes
16,416

Hi ABAP Gurus,

I wanted to convert my all currencies to USD, I have exchange rates in TCURR Table already.

I have used below code to call FM and used code for key figure (0DEB_CRE_LC) but the out values are become a ZERO.


DATA: L_KURST     type TCURR-KURST,  "exchg.rate type (M or variant)
        L_CURR_RATE type TCURR-UKURS,  "exchange rate value
        L_FC type TCURR-FCURR,  " From currency
        L_TC type TCURR-TCURR,  " To currency
        L_FF type TCURR-FFACT,
        L_TF type TCURR-TFACT,
       L_FA(16) type p.

    CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
         EXPORTING
              DATE             = SY-DATUM        "currency date
              FOREIGN_AMOUNT   = L_FA    "trans. currency amount
              FOREIGN_CURRENCY = L_FC       "trans. currency code
              LOCAL_CURRENCY   = 'USD'  "local currency
              TYPE_OF_RATE     = L_KURST        "rate on key date
              RATE             = L_CURR_RATE "rate from tcurr
         IMPORTING
              EXCHANGE_RATE    = L_CURR_RATE
              FOREIGN_FACTOR   = L_FF
              LOCAL_AMOUNT    = L_FA
              LOCAL_FACTOR     = L_TF
         EXCEPTIONS
            NO_RATE_FOUND    = 1
        OVERFLOW         = 2
        NO_FACTORS_FOUND = 3
        NO_SPREAD_FOUND  = 4
        OTHERS           = 5.


*  RESULT = 100.


Could you please check and let me know if am doing wrong.


Regards,

Vishu

View Entire Topic
Ashokv
Explorer
0 Likes

Hi,

I can see that FM is called immediately after definition of data. So no values for FOREIGN_AMOUNT, FOREIGN_CURRENCY,TYPE_OF_RATE is getting passed. Make sure that you pass some values into it.

RATE is optional. So you can either pass some value or comment it out.


Thanks,


Ashok Veer

Former Member
0 Likes

Hi Ashok, Right seems the above parameters are not getting any values as my key figure values are become a zero in SAP BW after DTP ran.


But i need to confirm one thing. If you see in SS, We have 0FISCAL YEAR/PERIOD as 2015007 but actually i have to treat it as 2015.01. whether it will cause to my issue.

I have exchange rates for 2015.01.

Could you please let me know where was the problem occurs?

Former Member
0 Likes

Hi Everybody.

I changed my code and it works fine.

Thanks everybody for help