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

CONVERT_TO_LOCAL_CURRENCY function

Former Member
0 Likes
3,923

Hi gurus,

I call this function, eg:

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

DATE = it_item-budat

FOREIGN_AMOUNT = it_item-dmbtr

FOREIGN_CURRENCY = it_item-waers

LOCAL_CURRENCY = it_item-waerk

IMPORTING

EXCHANGE_RATE = it_item-kursf

LOCAL_AMOUNT = it_item-wrbtr

Get error:

Function parameter "EXCHANGE_RATE" is unknown.

Pls help me fix it.

Edited by: Bach Mieu Nguyen on Dec 17, 2007 8:00 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,191

Try using this Type..

DATA: L_KURST LIKE TCURR-KURST, "exchg.rate ind.

L_CURR_RATE LIKE TCURR-UKURS. "exchange rate

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

DATE = P_CDATE "currency date

FOREIGN_AMOUNT = TRN_AMT "trans. currency amount

FOREIGN_CURRENCY = TRN_CURR "trans. currency code

LOCAL_CURRENCY = D_LOC_CURR "local currency

TYPE_OF_RATE = L_KURST "rate on key date

RATE = L_CURR_RATE "rate from tcurr

IMPORTING

EXCHANGE_RATE = L_CURR_RATE

FOREIGN_FACTOR = TCURR-FFACT

LOCAL_AMOUNT = NEW_LOC_AMT

LOCAL_FACTOR = TCURR-TFACT

EXCEPTIONS

NO_RATE_FOUND = 1.

6 REPLIES 6
Read only

Former Member
0 Likes
1,191

Check this thread below guess you will find a use full solution.

https://www.sdn.sap.com/irj/sdn/forums

Reward if found usefull.

Cheers,

Ram.

Read only

Former Member
0 Likes
1,192

Try using this Type..

DATA: L_KURST LIKE TCURR-KURST, "exchg.rate ind.

L_CURR_RATE LIKE TCURR-UKURS. "exchange rate

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

DATE = P_CDATE "currency date

FOREIGN_AMOUNT = TRN_AMT "trans. currency amount

FOREIGN_CURRENCY = TRN_CURR "trans. currency code

LOCAL_CURRENCY = D_LOC_CURR "local currency

TYPE_OF_RATE = L_KURST "rate on key date

RATE = L_CURR_RATE "rate from tcurr

IMPORTING

EXCHANGE_RATE = L_CURR_RATE

FOREIGN_FACTOR = TCURR-FFACT

LOCAL_AMOUNT = NEW_LOC_AMT

LOCAL_FACTOR = TCURR-TFACT

EXCEPTIONS

NO_RATE_FOUND = 1.

Read only

Former Member
0 Likes
1,191

Plese try this.

*If you get the error "No Rate Found" then go to the tcode OB08.*

This shows the existing currency exchange rates.

If your Currency conversion doesn't exist enter the From and To values.

*This should make the function module to work correctly.

*CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

DATE = sy-datum

FOREIGN_AMOUNT = '100'

FOREIGN_CURRENCY = 'US$'

LOCAL_CURRENCY = 'INR'

IMPORTING

EXCHANGE_RATE =

LOCAL_AMOUNT =

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.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Read only

Former Member
0 Likes
1,191

Hi Bach Mieu,

Check this out use this one......

You can Use the Following Function Module to convert from one Currency vale to other

In following function module we need to pass Foreign currency, Local Currency type_rate:Type of rate M=Average rate G=Bank buying rate B=bank selling rate

We Get Exchange rate for that day, foreign factor, Local factor.

And Foreign currency can be calculated as below mentioned in IF ENDIF

DATA: l_er TYPE tcurr-ukurs, "

l_ff TYPE tcurr-ffact,

l_lf TYPE tcurr-tfact,

l_erate(12) TYPE c,

CALL FUNCTION 'READ_EXCHANGE_RATE'

EXPORTING

date = sy-datum

foreign_currency = wa_bseg-pswsl

local_currency = c_euro

type_of_rate = 'M'

IMPORTING

exchange_rate = l_er

foreign_factor = l_ff

local_factor = l_lf

EXCEPTIONS

no_rate_found = 1

no_factors_found = 2

no_spread_found = 3

derived_2_times = 4

overflow = 5

OTHERS = 6.

IF sy-subrc = 0.

l_erate = l_er / ( l_ff / l_lf ).

wa_itab-wrbtr = wa_itab-wrbtr * l_erate.

ENDIF.

May be ur given exchange rate is not valid..... give the correct exchange rate...

Hope this may help you...

<b>Reward if useful</b>

regards,

sunil kairam.

Read only

0 Likes
1,191

Thanks for all,

But when I execute function CONVERT_TO_FOREIGN_CURRENCY as:

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

EXPORTING

date = it_item-budat

foreign_currency = it_item-waerk

local_amount = it_item-dmbtr

local_currency = it_item-waers

IMPORTING

exchange_rate = it_item-kursf "Exchange rate

foreign_amount = it_item-wrbtr. "Tax Amount(Document)

Don't have any error.

Read only

Former Member
0 Likes
1,191

Hi,

What is the type you are using for it_item-kursf? This should be of type TCURR-UKURS.

Thanks,

Sriram Ponna.