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

currency conversions

Former Member
0 Likes
731

hi

i have to convert the amount from currency x to y. If no conversion rates are defined for this then i have to choose some reference currency (TCURV-BWAER) ex USD so that i can convert from X -> USD -> Y.

this will give my target amount.

But in order to calculate the rate ( X - > USD -> Y) what is procedure since i want

__________________________{ X rate USD rate Y}

to use the rate in other function module for the currencies which donot have rates defined in TCURR

hi

i have to convert the amount from currency x to y. If no conversion rates are defined for this then i have to choose some reference currency (TCURV-BWAER) ex USD so that i can convert from X -> USD -> Y.

this will give my target amount.

But in order to calculate the rate ( X - > USD -> Y) what is procedure since i want

__________________________{ X rate USD rate Y}

to use the rate in other function module for the currencies which donot have rates defined in TCURR

4 REPLIES 4
Read only

Former Member
0 Likes
668

HI,

Below is the code for converting currency values from one currency to another.

DATA: gd_fcurr TYPE tcurr-fcurr,
      gd_tcurr TYPE tcurr-tcurr,
      gd_date  TYPE sy-datum,
      gd_value TYPE i.

gd_fcurr = 'EUR'.
gd_tcurr = 'GBP'.
gd_date  = sy-datum.
gd_value = 10.

PERFORM currency_conversion USING gd_fcurr
                                  gd_tcurr
                                  gd_date
                         CHANGING gd_value.



* Convert value to Currency value 
*&---------------------------------------------------------------------*
*&      Form  currency_conversion
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_GD_FCURR  text
*      -->P_GD_TCURR  text
*      -->P_GD_DATE   text
*      <--P_GD_VALUE  text
*----------------------------------------------------------------------*
FORM currency_conversion  USING    p_fcurr
                                   p_tcurr
                                   p_date
                          CHANGING p_value.

  DATA: t_er        TYPE tcurr-ukurs,
        t_ff        TYPE tcurr-ffact,
        t_lf        TYPE tcurr-tfact,
        t_vfd       TYPE datum,
        ld_erate(12)   TYPE c.

  CALL FUNCTION 'READ_EXCHANGE_RATE'
    EXPORTING
*       CLIENT                  = SY-MANDT
      date                    = p_date
      foreign_currency        = p_fcurr
      local_currency          = p_tcurr
      TYPE_OF_RATE            = 'M'
*       EXACT_DATE              = ' '
   IMPORTING
      exchange_rate           = t_er
      foreign_factor          = t_ff
      local_factor            = t_lf
      valid_from_date         = t_vfd
*       DERIVED_RATE_TYPE       =
*       FIXED_RATE              =
*       OLDEST_RATE_FROM        =
   EXCEPTIONS
     no_rate_found           = 1
     no_factors_found        = 2
     no_spread_found         = 3
     derived_2_times         = 4
     overflow                = 5
     zero_rate               = 6
     OTHERS                  = 7
            .
  IF sy-subrc EQ 0.
    ld_erate = t_er / ( t_ff / t_lf ).
    p_value = p_value * ld_erate.
  ENDIF.
ENDFORM.                    " currency_conversion

See the below link for explanation and a Program

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/fmCurrencyConversion&

Regards

Sudheer

Read only

ashok_kumar24116
Contributor
0 Likes
668

Hi Kiran,

Good, Check the following

Currency Convertion (i.e. from EUR to GBP):

http://www.sapdevelopment.co.uk/country/country_curr.htm

Convert currency value from internal(SAP) to external(display)

http://www.sapdevelopment.co.uk/country/country_inttoext.htm

Just you can check it out in SE37.

CONVERT_TO_LOCAL_CURRENCY_N

CONVERT_TO_LOCAL_CURRENCY_O.

CONVERT_TO_FOREIGN_CURRENCY

Chk this Link

Good Luck and Thanks

AK

hope this helps.

Read only

Former Member
0 Likes
668

Hi sudheer & AK,

If you check the function module 'READ_EXCHANGE_RATE' (SE37 - it will be easy) for fcurr is MYR and Lcurr is ZAR. then u will get exception.

I want to eliminate this exception.

Means calculate

!) rate for MYR to Intermediate currency(ex USD).

2) rate for intermediate currency(USD) to ZAR.

Then using this 2 rates<u> how to decide the final rate for MYR -> ZAR conversion.</u>

please check this

Read only

0 Likes
668

Can any one help me in finding this