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: 

Currency Conversion?

Former Member
0 Kudos

HI all,

Any FM to convert GBP to EURO?

Sanjeev.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Sanjeev,

Welcome to SDN.

Before posting always search for the topic in SDN. If do not get any solution then go for posting a question.

This can be done using the function modules:

CONVERT_TO_LOCAL_CURRENCY .

CONVERT_TO_FOREIGN_CURRENCY.

Try the following example:

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

date = sy-datum

foreign_amount = x_booking-forcuram

foreign_currency = x_booking-forcurkey

local_currency = local_currency

IMPORTING

  • exchange_rate =

  • foreign_factor = fremdkurs

local_amount = local_amount

  • local_factor =

  • exchange_ratex = faktorsum

  • 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.

Hope this helps you.

Regards,

Chandra Sekhar

5 REPLIES 5

Former Member
0 Kudos

Hi

U can use the fms CONVERT_TO_FOREIGN_CURRENCY or CONVERT_TO_LOCAL_CURRENCY

Max

0 Kudos

Hai MAX,

I need some more which are relevant to the same.

Sanjeev.

0 Kudos

Hi

U should a code like this:

DATA: CHANGE_DATE      LIKE  SYST-DATUM,
      FOREIGN_CURRENCY TYPE WAERS,
      LOCAL_CURRENCY   TYPE WAERS,
      LOCAL_AMOUNT     TYPE WRBTR,
      FOREIGN_AMOUNT   TYPE WRBTR.


* Set the date for the change

CHANGE_DATE = SY-DATUM.

* If GBP is local currency and EUR is foreign currency

LOCAL_CURRENCY   = 'GBP'.
FOREIGN_CURRENCY = 'EUR'.

MOVE 1000 TO LOCAL_AMOUNT.

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
     EXPORTING
          DATE             = CHANGE_DATE
          FOREIGN_CURRENCY = FOREIGN_CURRENCY
          LOCAL_AMOUNT     = LOCAL_AMOUNT
          LOCAL_CURRENCY   = LOCAL_CURRENCY
     IMPORTING
          FOREIGN_AMOUNT   = FOREIGN_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.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
  WRITE: 'Local amount   :', LOCAL_AMOUNT CURRENCY LOCAL_CURRENCY,
                                                         LOCAL_CURRENCY,
         /'Foreign amount:', FOREIGN_AMOUNT CURRENCY FOREIGN_CURRENCY,
                                                       FOREIGN_CURRENCY.
ENDIF.

SKIP 2.
* If GBP is foreign currency currency and EUR is local currency

FOREIGN_CURRENCY = 'GBP'.
LOCAL_CURRENCY   = 'EUR'.


MOVE 1000 TO FOREIGN_AMOUNT.

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
     EXPORTING
          DATE             = CHANGE_DATE
          FOREIGN_AMOUNT   = FOREIGN_AMOUNT
          FOREIGN_CURRENCY = FOREIGN_CURRENCY
          LOCAL_CURRENCY   = LOCAL_CURRENCY
     IMPORTING
          LOCAL_AMOUNT     = LOCAL_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.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
  WRITE:  'Foreign amount:', FOREIGN_AMOUNT CURRENCY FOREIGN_CURRENCY,
                                                       FOREIGN_CURRENCY,
         /'Local amount   :', LOCAL_AMOUNT CURRENCY LOCAL_CURRENCY,
                                                         LOCAL_CURRENCY.
ENDIF.

Which function module to be used should be decided in order to the company code currency (local currency).

If the currencies you're using aren't the currency of company code u can use the fm u prefer.

Max

Former Member

Former Member
0 Kudos

Hi Sanjeev,

Welcome to SDN.

Before posting always search for the topic in SDN. If do not get any solution then go for posting a question.

This can be done using the function modules:

CONVERT_TO_LOCAL_CURRENCY .

CONVERT_TO_FOREIGN_CURRENCY.

Try the following example:

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

date = sy-datum

foreign_amount = x_booking-forcuram

foreign_currency = x_booking-forcurkey

local_currency = local_currency

IMPORTING

  • exchange_rate =

  • foreign_factor = fremdkurs

local_amount = local_amount

  • local_factor =

  • exchange_ratex = faktorsum

  • 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.

Hope this helps you.

Regards,

Chandra Sekhar