Application Development 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: 

Function module for Currency conversion is required.

Former Member
0 Kudos

If a purchase request amount is in one currency, I need to convert to "EUR" currency.

Please let me know the Function module / conversion routine.

If there is any specific FM/routine exists to convert European currencies (like GBP/SEK/DEK/NEK/ swiss fanc) to "EURO", then also please let me know.

Thanks in advance!

6 REPLIES 6

Pawan_Kesari
Active Contributor
0 Kudos

CONVERT_TO_LOCAL_CURRENCY

Former Member
0 Kudos

Hi Kpreddy

if use this FM it should work fine

CONVERT_TO_LOCAL_CURRENCY

If need to know what to pass in just let me know and I'll post and example

Conor.

Former Member
0 Kudos

Hi,

Here is the example program to convert the currency



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


Regards

Sudheer

Former Member
0 Kudos

Hi,

Try

CURRENCY_CONVERTING_FACTOR - multiply/divide factor for a currency

BAPI_CURRENCY_CONV_TO_EXTERNAL - Conversion of Currency Amounts into External Data Format

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

Former Member
0 Kudos

Hi

these are the Fm availavble in sap on currency

<b>Amount and currency functions</b>

<b>CURRENCY_AMOUNT_SAP_TO_IDOC</b> - Convert currency to IDOC format

<b>CONVERT_TO_LOCAL_CURRENCY </b> - Conversion of currency

<b>HRCM_AMOUNT_TO_STRING_CONVERT</b> - Convert amount to string

<b>HRCM_STRING_TO_AMOUNT_CONVERT</b> - Convert amount from string

<b>CLOI_PUT_SIGN_IN_FRONT</b> Move the negative sign from the left hand side of a number, to the right hand side of the number. Note that The result will be left justified (like all

character fields), not right justifed as numbers normally are.

<b>CONVERT_TO_FOREIGN_CURRENCY</b> Convert local currency to foreign currency.

<b>CONVERT_TO_LOCAL_CURRENCY</b> Convert from foreign currency to local currency

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

Former Member
0 Kudos

Hi, You can use the below FM :-

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

date = gv_firstday1 ====> date to be mentioned

foreign_amount = 123.00 ====> Give the Amount to which to currency

foreign_currency = 'GBP' ====>To Currency

local_currency = 'USD' ====>From Currency

type_of_rate = 'M' ====> Type of rate (Month begin type)

IMPORTING

exchange_rate = cv_lv_ukurs =====> Exchnage rate on the day

local_amount = cv_vallc1 =====> Amount after calculation amt

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.

Thanks,

Sri.