‎2005 Nov 23 9:55 AM
Hi,
I have two fields which contains JPY currency.
I want to convert into USD using function module.I have coded two times for two fields.Is there any way to write one time to get currencies for two fields?
if t_bill-WAERK ne 'USD'.
for JPY
if t_bill-WAERK eq 'JPY'.
t_bill-NETWR = t_bill-NETWR * 100.
endif.
*for netwr
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
CLIENT = SY-MANDT
DATE = t_bill-FKDAT
FOREIGN_AMOUNT = t_bill-NETWR
FOREIGN_CURRENCY = t_bill-WAERK
LOCAL_CURRENCY = 'USD'
IMPORTING
LOCAL_AMOUNT = v_bilamt.
*for netpr
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
CLIENT = SY-MANDT
DATE = t_bill-FKDAT
FOREIGN_AMOUNT = t_bill-NETPR
FOREIGN_CURRENCY = t_bill-WAERK
LOCAL_CURRENCY = 'USD'
IMPORTING
LOCAL_AMOUNT = v_tp.
else.
v_bilamt = t_bill-netwr.
v_tp = t_bill-netpr.
endif.
points guaranteed
cheers
kaki
‎2005 Nov 23 9:57 AM
Hi
Pass your currency in an itab then use the below code.
LOOP AT ITAB.
Call the FM.
ENDLOOP.
‎2005 Nov 23 10:04 AM
YOu cannot reduce the number of times the FM is beign called. You can reduce the length of the code by writing a Perform for the function call.
perfrom Change_currency using t_bill-NETWR t_bill-waerk
changing v_bilamt.
perfrom Change_currency using t_bill-NETpr t_bill-waerk
changing v_tp.
‎2005 Nov 23 10:11 AM
if t_bill-WAERK ne 'USD'.
* for JPY
if t_bill-WAERK eq 'JPY'.
t_bill-NETWR = t_bill-NETWR * 100.
endif.
*for netwr
perform convert_currency using t_bill-fkdat
t_bill-netwr
t_bill-waerk
changing v_bilamt.
*for netpr
perform convert_currency using t_bill-fkdat
t_bill-netpr
t_bill-waerk
changing v_tp.
else.
v_bilamt = t_bill-netwr.
v_tp = t_bill-netpr.
endif.form convert_currency using fkdate type sy-datum
price type netpr
waerk type waerk
changing val type netpr.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
CLIENT = SY-MANDT
DATE = fkdate
FOREIGN_AMOUNT = price
FOREIGN_CURRENCY = WAERK
LOCAL_CURRENCY = 'USD'
IMPORTING
LOCAL_AMOUNT = val.
endform.regards
vijay
‎2005 Nov 23 10:17 AM
hi,
I think you can try using the FM Read_exchange_rate . This can be called only once to get the exchange rate for the currencies which can then be used to calculate the values of the two fields.
Regards,
Kalpana