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

Exchange rate

Former Member
0 Likes
577

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.

1 ACCEPTED SOLUTION
Read only

Manohar2u
Active Contributor
0 Likes
545

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.

2 REPLIES 2
Read only

Former Member
0 Likes
545

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.

Read only

Manohar2u
Active Contributor
0 Likes
546

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