‎2007 Jun 08 6:31 AM
Hi Friends,
i want to convert CAD in to USD Dollar,but if use this function module ,its converting,but slight difference is coming in the values ,this is becoz the exchange rate is not updatd in this FM.
EG: 1 dollar equalt to 40.2 now
but this function module is showing 45.
can any one please tell how to rectify it.or any other function module is der for this
DATA : L_NETWR TYPE VBAP-NETWR.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = SY-DATUM
FOREIGN_AMOUNT = '10.00'
FOREIGN_CURRENCY = 'CAD'
LOCAL_CURRENCY = 'USD'
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.
‎2007 Jun 08 6:34 AM
HI,
Here is the Example program
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
‎2007 Jun 08 6:36 AM
hi
good
if you look at table TCURX, the # of decimals for LUF is 0. This means that the value that is stored in the DB and the value that you work with in your program should actually be 100 times smaller than the actual value. TCURX is used to adjust the value when you WRITE it out using the CURRENCY attribute,so check your value that you are passing,
Thanks
mrutyun^