Skip to Content
author's profile photo Former Member
Former Member

FM to convert any Currency to US dollar.

Hi ABAPers,

Is there any Fm to convert any currency to US dollars,

where the user also provides the conversion rate ??

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 19, 2008 at 10:00 AM

    This fm can help you

    CONVERT_TO_LOCAL_CURRENCY

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 19, 2008 at 10:06 AM

    hi,

    DATA: p_date TYPE SY-DATUM,

    pf_amt TYPE P DECIMALS 2,

    pl_amt TYPE P DECIMALS 2.

    CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

    EXPORTING

    • CLIENT = SY-MANDT

    DATE = p_date

    FOREIGN_AMOUNT = pf_amt

    FOREIGN_CURRENCY = USD

    LOCAL_CURRENCY = INR

    • RATE = 0

    • TYPE_OF_RATE = 'M'

    • READ_TCURR = 'X'

    • IMPORTING

    • EXCHANGE_RATE =

    • FOREIGN_FACTOR =

    LOCAL_AMOUNT = pl_amt

    • LOCAL_FACTOR =

    • EXCHANGE_RATEX =

    • FIXED_RATE =

    • DERIVED_RATE_TYPE =

    • EXCEPTIONS

    • NO_RATE_FOUND = 1

    • OVERFLOW = 2

    • NO_FACTORS_FOUND = 3

    • NO_SPREAD_FOUND = 4

    • DERIVED_2_TIMES = 5

    • OTHERS = 6

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      In CONVERT_TO_LOCAL_CURRENCY

      functionmodule.. you have to pass the date in order to get the exchange rate, for that currency on that particular day.

      Otherwise, you got to specify the exchange rate manually in the parameter RATE, which might be a problem in case, the currency from which you are converting keeps on changin.

      Regards.

  • author's profile photo Former Member
    Former Member
    Posted on Nov 19, 2008 at 10:10 AM

    hi

    you can use the fm CONVERT_TO_LOCAL_CURRENCY

    also ther are FM'S

    CONVERT_TO_LOCAL_CURRENCY_N-is used to Translate local currency amount into foreign currency and

    CONVERT_TO_LOCAL_CURRENCY_O-is used to Translate foreign currency amount to local currency

    hope this helps

    regards

    Aakash

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 19, 2008 at 10:10 AM

    hi,

    you can use function module : CONVERT_TO_LOCAL_CURRENCY

    example code:

    CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
          EXPORTING
            date             = vbdkr-fkdat
            foreign_amount   = hkomvd-kwert
            foreign_currency = vbdkr-waerk
            local_currency   = t001-waers
            rate             = vbdkr-kurrf
          IMPORTING
            local_amount     = komvdk_ch-kwert
          EXCEPTIONS
            no_rate_found    = 1
            overflow         = 2
            no_factors_found = 3
            no_spread_found  = 4
            OTHERS           = 5.

    thanks and regards

    rahul

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 20, 2008 at 07:10 AM

    THe conversion v to local currency to dollar depends on the the value dollar has on that particular day.

    So depending on you r requirement use some particular date or sy-datum can be used to get the value on the day the report is executed.

    CONVERT_TO_LOCAL_CURRENCY can be used passing date as sy-datum.

    Hope this helps.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 27, 2015 at 08:55 AM

    Hello Michael,

    I have the same scenario here.

    I want to convert any currency to only USD.

    example ->

    INR to USD

    DKK to USD

    CAD to USD

    JPY to USD

    Basically any amount any currency to USD.

    Below is my code ->

    DATA : w_dec1 LIKE tcurx-currdec,

    w_amt LIKE bsid-dmbtr,

    w_rate LIKE tcurr-ukurs,

    w_fact1 LIKE tcurr-ffact,

    w_fact2 LIKE tcurr-ffact.

    DATA : lv_amt1 LIKE bsid-wrbtr.

    CALL FUNCTION 'FWOS_CURRENCY_DECIMALS_READ'

    EXPORTING

    i_currency = im_fcurr

    IMPORTING

    e_decimals = w_dec1

    EXCEPTIONS

    i_currency_initial = 1

    OTHERS = 2.

    IF sy-subrc <> 0.

    w_dec1 = 2.

    ENDIF.

    lv_amt1 = im_wrbtr * 10 ** ( w_dec1 - 2 ).


    CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

    EXPORTING

    date = sy-datum

    foreign_amount = lv_amt1

    foreign_currency = im_fcurr

    local_currency = im_tcurr

    * rate = 0

    * type_of_rate = 'M'

    read_tcurr = 'X'

    IMPORTING

    exchange_rate = w_rate

    foreign_factor = w_fact1

    local_amount = w_amt

    local_factor = w_fact2

    * EXCHANGE_RATEX =

    * FIXED_RATE =

    * DERIVED_RATE_TYPE =

    EXCEPTIONS

    no_rate_found = 1

    overflow = 2

    no_factors_found = 3

    no_spread_found = 4

    derived_2_times = 5

    OTHERS = 6.


    IF sy-subrc EQ 0.

    e_wrbtr = w_amt.

    ENDIF.


    Problem ->


    Case 1 : INR to USD


    I pass From-Currency INR, Amount 115895.67, Date is sy-datum and To-Currency USD.


    Result which i get is 2000 USD which is correct.



    Case 2 : DKK to USD


    I pass From-Currency DKK, Amount 100, Date is sy-datum and To-Currency USD.


    Result which i get is 17.39 USD. But actually the amount expected is 17.72


    expected -


    I even passed date as 03.03.2005 and i still see 17.39 USD as output.


    Case 3 :CAD to USD


    I pass From-Currency CAD, Amount 200, Date is sy-datum and To-Currency USD.


    Result which i get is 186.71 USD. But actually the amount expected is 217.57.


    expected -


    I even Passed date as 09.10.208 and i still see 186.71 USD as output.


    I am unable to figure out why there is difference during the conversion.


    Can you please here ?


    Regards,

    Ashwin



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.