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 Problem

Former Member
0 Likes
603

Dear All,

I want convert INR currecny to USD dollor currency. In my program it display result 0. I want sample program for currecny conversion. I have include my program for persual.

DATA: xrate TYPE f,

lamt TYPE p,

ffact TYPE f,

lfact TYPE f.

PARAMETERS: fcurr LIKE tcurc-waers,

lcurr LIKE tcurc-waers,

famt TYPE p.

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

EXPORTING

CLIENT = SY-MANDT

date = sy-datum

foreign_currency = fcurr

local_amount = lamt

local_currency = lcurr

RATE = 50

TYPE_OF_RATE = 'M'

READ_TCURR = 'X'

IMPORTING

exchange_rate = xrate

foreign_amount = famt

foreign_factor = ffact

local_factor = lfact

  • EXCHANGE_RATEX =

  • DERIVED_RATE_TYPE =

  • FIXED_RATE =

EXCEPTIONS

no_rate_found = 1

overflow = 2

no_factors_found = 3

no_spread_found = 4

derived_2_times = 5

OTHERS = 6.

.

IF sy-subrc EQ 0.

WRITE:/ lamt, 'converted from',lcurr, 'to',fcurr, 'is:',famt.

WRITE:/ 'exchange rate',xrate,

/ 'foreign factor',ffact,

/ 'local factor',lfact.

ELSE.

WRITE:/ lamt, 'not converted'.

ENDIF.

With Regards,

Sathish M.R

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
554

Hi,

I dont think you need to mention the parameter value RATE = 50.

If the exchange rates are maintained in the system, the func module will check the latest based on date and do the conversion.

Regards,

Subramanian

4 REPLIES 4
Read only

Former Member
0 Likes
555

Hi,

I dont think you need to mention the parameter value RATE = 50.

If the exchange rates are maintained in the system, the func module will check the latest based on date and do the conversion.

Regards,

Subramanian

Read only

NAeda
Contributor
0 Likes
554

use this.

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
      EXPORTING
           DATE = EKBE-BUDAT
           LOCAL_AMOUNT = EKBE-DMBTR   "XEBEFU-NETWR
           FOREIGN_CURRENCY = EKKO-WAERS  "EKKO-WAERS
           LOCAL_CURRENCY = T001-WAERS "T001-WAERS
*                  TYPE_OF_RATE   = KURSTYP
      IMPORTING
           FOREIGN_AMOUNT = I_WRBTR .  "XEBEFU-NETWR

Edited by: Aeda N on Dec 3, 2009 1:01 PM

Edited by: Aeda N on Dec 3, 2009 1:04 PM

Read only

former_member156446
Active Contributor
0 Likes
554

First the exchange rates should be maintained in the table TCURR. Please check this.

Also check the below sample.

DATA : L_NETWR TYPE VBAP-NETWR.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
     EXPORTING
          DATE             = SY-DATUM
          FOREIGN_AMOUNT   = '18'
          FOREIGN_CURRENCY = 'INR'
          LOCAL_CURRENCY   = 'USD'
   TYPE_OF_RATE            = 'M'
     IMPORTING
          LOCAL_AMOUNT     = L_NETWR
     EXCEPTIONS
          NO_RATE_FOUND    = 1
          OVERFLOW         = 2
          NO_FACTORS_FOUND = 3
          NO_SPREAD_FOUND  = 4
          DERIVED_2_TIMES  = 5
          OTHERS           = 6.

WRITE: L_NETWR.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
554

Hello Satish,

Please check in table TCURR what is the exch. rate type maintained for INR to USD.

As mentioned by J@y the exch. rate must be maintained in TCURR for this FM to behave correctly. Also one thing to note is: are the variables fcurr, lcurr & lamt populated correctly during the FM call?

BR,

Suhas