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 conversion

Former Member
0 Likes
1,062

Hi,

Could u pls help me to convert US dollar to EURO?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
875

Hi,

Check this example

DATA: v_amount TYPE p DECIMALS 2.

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

EXPORTING

date = sy-datum

foreign_currency = 'INR'

local_amount = '1.00'

local_currency = 'USD'

IMPORTING

foreign_amount = v_amount

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.

WRITE: / 'US dollar to Indian rupees - ', v_amount.

ENDIF.

Kishore.

6 REPLIES 6
Read only

Former Member
0 Likes
876

Hi,

Check this example

DATA: v_amount TYPE p DECIMALS 2.

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

EXPORTING

date = sy-datum

foreign_currency = 'INR'

local_amount = '1.00'

local_currency = 'USD'

IMPORTING

foreign_amount = v_amount

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.

WRITE: / 'US dollar to Indian rupees - ', v_amount.

ENDIF.

Kishore.

Read only

Former Member
0 Likes
875

hi,

Use FM

CONVERT_TO_FOREIGN_CURRENCY
CONVERT_TO_LOCAL_CURRENCY

Regards,

Santosh

Read only

0 Likes
875
      CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'     " Convert to Manuf
           EXPORTING                                  " currency
                DATE             = ZVBRP-PRSDT
*               date             = sy-datum
                FOREIGN_CURRENCY = T001-WAERS
                LOCAL_AMOUNT     = Z1KOMV-KWERT
                LOCAL_CURRENCY   = Z1KOMV-WAERS
*               RATE             = 0
                TYPE_OF_RATE     = 'M'
           IMPORTING
                FOREIGN_AMOUNT   = Z1KOMV-KWERT
           EXCEPTIONS
                NO_RATE_FOUND    = 1
                OVERFLOW         = 2
                NO_FACTORS_FOUND = 3
                NO_SPREAD_FOUND  = 4
                OTHERS           = 5.
      IF SY-SUBRC IS INITIAL.
        IRPT-CINVAMT = IRPT-CINVAMT + Z1KOMV-KWERT.
      ENDIF.

You can even use <b>MS_CONVERT_TO_OTHER_CURRENCY</b>

Read only

Former Member
0 Likes
875

Try this......

SD_CONVERT_CURRENCY

Read only

anversha_s
Active Contributor
0 Likes
875

hi,

check this it may help you......

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
       EXPORTING
*    CLIENT                  = 001
        DATE                    = sy-datum
         FOREIGN_CURRENCY        = wa1-WAERS " here you need to declare your foreign currency i.e EURO
         LOCAL_CURRENCY          = TCURR-FCURR "give USD
         FOREIGN_AMOUNT          = wa1-DMBTR " here you need to declare your amount field.
*    RATE                    = tcurr-ukurs
        TYPE_OF_RATE            = 'M'        " check this also the average rate
*    READ_TCURR              = 'X'
      IMPORTING
        EXCHANGE_RATE           = tcurr-UKURS
*    FOREIGN_FACTOR          =
        LOCAL_AMOUNT            = wa1-TOTAL  " this is the field where the converted amt has to be displayed.
*    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.

Translate foreign currency amount to local currency

An amount in local currency is calculated from a specified foreign currency amount.

For this, you may either specify the translation rate manually (Parameter RATE)

or have the system determine it from table TCURR on the basis of the rate type, date and currency key.

Because the ratios for the units of the currencies involved in the translation are significant for this translation,

table TCURF is always read by the program, and there must be a valid entry there for the data specified.

IF exchange rate fixing is defined for the exchange rate type TYPE_OF_RATE or an alternative exchange rate is defined for the currency pair, this information is transferred to the calling program.

When table TCURR is read, the foreign currency key is always taken as the first part of the key and the local currency as the second part.

hope this helps you.

regards,

Anversha.S

Read only

Former Member
0 Likes
875

CALL FUNCTION 'SD_CONVERT_CURRENCY'

EXPORTING

i_date = sy-datum

i_source_amount = vbap-zwert " Source Amt

i_source_currency = vbak-waerk " Source Currency

i_local_currency = vbak-waers " Local Currency

i_target_currency = w_waers " Target Currency

IMPORTING

e_target_amount = lv_zwert " Target Amount

EXCEPTIONS

no_rate_found = 1.