2006 Jul 16 12:40 AM
Hi,
I need to find the exchange rate basing on the posting date, if posting date is not between the GDATU then it has to check from the previous dates in GDATU.
Please any one let me know how to do this?
Thanks,
Pavan.
2006 Jul 16 11:32 AM
1. Ok. In this case you have to select all entries
select * from tcurr into table itab where FCURR = final_tab-waers and TCURR = 'INR' .2. Then
sort itab gdatu.
read table itab with key gdatu = postdate.
if sy-subrc = 0.
result = gdatu.
else.
loop at itab where GDATU <= postdate.
at first.
result = gdatu.
endat.
endloop.
endif.Regds
Manohar
Hi,
I need to find the exchange rate basing on the posting date, if posting date is not between the GDATU then it has to check from the previous dates in GDATU.
Please any one let me know how to do this?
Thanks,
Pavan.
2006 Jul 16 11:19 AM
Not sure about GDATU..may be the below logic/
FM can help you...
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = date
FOREIGN_AMOUNT = in_amt
FOREIGN_CURRENCY = in_curr
LOCAL_CURRENCY = out_curr
TYPE_OF_RATE = type_of_rate
IMPORTING
EXCHANGE_RATE = ukurs
FOREIGN_FACTOR = ffact
LOCAL_FACTOR = tfact
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5
OTHERS = 6.
IF SY-SUBRC <> 0.
if sy-subrc = 1.
raise no_rate_found.
elseif sy-subrc = 3.
raise no_factors_found.
elseif sy-subrc = 4.
raise no_spread_found.
elseif sy-subrc = 5.
raise derived_2_times.
endif.
ENDIF.
sign = sign( ukurs ).
if sign lt 0.
ukurs = ukurs * sign.
if not ffact is initial.
out_amt = in_amt * tfact / ukurs / ffact.
else.
out_amt = in_amt / ukurs.
endif.
else.
if not ffact is initial.
out_amt = in_amt * ukurs * tfact / ffact.
else.
out_amt = in_amt * ukurs.
endif.
endif.
2006 Jul 16 11:32 AM
1. Ok. In this case you have to select all entries
select * from tcurr into table itab where FCURR = final_tab-waers and TCURR = 'INR' .2. Then
sort itab gdatu.
read table itab with key gdatu = postdate.
if sy-subrc = 0.
result = gdatu.
else.
loop at itab where GDATU <= postdate.
at first.
result = gdatu.
endat.
endloop.
endif.Regds
Manohar