10-03-2008 10:19 PM
Hi Experts,
I need to convert the 100 AMOUNT value from CHF currency to USD currency.
So, am using FMs - CONVERT_TO_LOCAL_CURRENCY and MS_CONVERT_TO_OTHER_CURRENCY..........but none of these r giving the results!!!!!!!!!
My code is as follows,
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = sy-datum
foreign_amount = wa_alv-kbetr_chf
foreign_currency = 'CHF'
local_currency = 'USD'
TYPE_OF_RATE = 'M'
IMPORTING
LOCAL_AMOUNT = wa_alv-kbetr_usd.
So, let me know that,
1 - Wht is the mistake in my code?
2 - Is there any good FM to get dome my work?
thanq
10-03-2008 10:38 PM
You have not included the exceptions in your call to the FM. Please do that and check SY-SUBRC. The exception could be NO_RATE_FOUND (meaning that the exchange rate is not defined in table TCURR).
You can use transaction S_BCE_68000174 to maintain exchange rates.
Rob
Edited by: Rob Burbank on Oct 3, 2008 5:53 PM
10-03-2008 10:38 PM
You have not included the exceptions in your call to the FM. Please do that and check SY-SUBRC. The exception could be NO_RATE_FOUND (meaning that the exchange rate is not defined in table TCURR).
You can use transaction S_BCE_68000174 to maintain exchange rates.
Rob
Edited by: Rob Burbank on Oct 3, 2008 5:53 PM
10-04-2008 8:49 AM
Hi,
Please check the sample code
REPORT z_test_subha2.
DATA: l_local TYPE kwert VALUE '100',
l_foren TYPE kbetr,
l_for TYPE waers VALUE 'USD',
l_loc TYPE waers VALUE 'CHF'.
DATA : l_rate TYPE ukurs_curr,
l_rate_type TYPE kurst_curr,
l_l_fact TYPE i,
l_f_fact TYPE i.
CALL FUNCTION 'READ_EXCHANGE_RATE'
EXPORTING
client = sy-mandt
date = sy-datum
foreign_currency = l_loc
local_currency = l_for
type_of_rate = 'M'
IMPORTING
exchange_rate = l_rate
foreign_factor = l_f_fact
local_factor = l_l_fact
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.
IF l_rate LE 0.
l_rate = l_rate * -1.
ENDIF.
l_foren = l_local * l_rate .
ENDIF.
WRITE: l_foren.
10-04-2008 9:14 AM