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 convertion

Former Member
0 Likes
1,327

currency convertion

i want to convert currency  from sap internal currency to deffrent courency (local as per the country)

please can any body help me

Moderator message: FAQ, please search for available information before posting.

Message was edited by: Thomas Zloch

currency convertion

i want to convert currency  from sap internal currency to deffrent courency (local as per the country)

please can any body help me

Moderator message: FAQ, please search for available information before posting.

Message was edited by: Thomas Zloch

8 REPLIES 8
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,254

(FAQ) look for information on FM CONVERT_TO_LOCAL_CURRENCY (and CONVERT_TO_FOREIGN_CURRENCY)

Regards,

Raymond

Read only

Former Member
0 Likes
1,254

Check the following code:

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.


LOCAL_CURRENCY   = 'USD'.
FOREIGN_CURRENCY = 'BRL'.

MOVE 20000 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  ne 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.


FOREIGN_CURRENCY = 'BRL'.
LOCAL_CURRENCY   = 'USD'.


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

Read only

0 Likes
1,254

thanks Krupa Janiji

but if the currency that want to convert is in sap  table BSIS-waers

and program should outomaticly converted to local currency whitout Specify  the currency ??

so if me in UAE it convert to UAE currency if me in oman it convert to oman currency

hope u understand my point

Read only

0 Likes
1,254

Hi Safiya,

  By using T005 table, u can get the currency key for the corresponding country. Then u can assign the currency code to FOREIGN_CURRENCY before calling the FM 'CONVERT_TO_FOREIGN_CURRENCY' .

Thanks.

Dhivya.

Read only

former_member308418
Participant
0 Likes
1,254

Hi,

You can use the FM 'CONVERT_TO_LOCAL_CURRENCY'.

regards,

tania.

Read only

Dhivya
Active Participant
0 Likes
1,254

Hi,

FM used is

CONVERT_TO_FOREIGN_CURRENCY Convert local currency to foreign currency.

Pls go through the below link for conversion using BAPI

http://help.sap.com/saphelp_nw04/helpdata/en/a5/3ec9ea4ac011d1894e0000e829fbbd/content.htm

Read only

Former Member
0 Likes
1,254

HI

still in oman its 3 desimal but the result come 2 decimal

how can solve the problem

Read only

Dhivya
Active Participant
0 Likes
1,254

Hi Safiya,

 

   In table TCURX, for OMAN 3 decimal places is allocated. So only u r getting like that.