07-30-2007 12:57 PM
Hi friends,
I have two fields one is dmbtr(amount in local currency) and hwaer(currency). As of now it is displaying like 100 usd
150 skk
200 eur
But I need to change all currencys to skk that means above I need to change to
100 skk
150 skk
200 skk.
How to use the function module convert_to_local_currency I mean what are the parameters I need to pass.
Please send me some sample code for the above requirement.
Thanks to all.
07-30-2007 12:59 PM
Hi,
&----
*& Report Z_BARRY_CONVERT_CURRENCY *
*& *
&----
*& *
*& *
&----
REPORT z_barry_convert_currency .
DATA: jine LIKE bseg-wrbtr .
DATA: date LIKE sy-datum .
date = '20070519' .
DATA: fa LIKE bseg-wrbtr ,
fc LIKE t001-waers ,
lc LIKE t001-waers ,
ty like tcurr-KURST .
fa = 3 .
fc = 'EUR' .
lc = 'ATS' .
ty = 'M'.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = date
foreign_amount = fa
foreign_currency = fc
local_currency = lc
type_of_rate = ty
IMPORTING
local_amount = jine
EXCEPTIONS
no_rate_found = 1
OTHERS = 2.
WRITE:/ jine .
Regards
Sudheer
07-30-2007 1:00 PM
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING DATE = BKPF-WWERT
FOREIGN_CURRENCY = BKPF-WAERS
LOCAL_CURRENCY = T001-WAERS
FOREIGN_AMOUNT = BSEG-WRBTR
RATE = BKPF-KURSF
TYPE_OF_RATE = 'M'
IMPORTING EXCHANGE_RATE = KURS
LOCAL_AMOUNT = BSEG-DMBTR
FOREIGN_FACTOR = FAKTOR-F
LOCAL_FACTOR = FAKTOR-L
FIXED_RATE = FIXKURS
EXCEPTIONS NO_RATE_FOUND = 4
NO_FACTORS_FOUND = 8.
open Transaction se37 , neter the FM name as CONVERT_TO_LOCAL_CURRENCY, display, now in tool bar click the "function module documentation" button for more info.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = SY-DATUM
FOREIGN_AMOUNT = foreign_amount
FOREIGN_CURRENCY = t005-curha "USD
LOCAL_CURRENCY = T000-MWAER "GBP
IMPORTING
LOCAL_AMOUNT = LOCAL_AMOUNT
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = SYST-DATUM
FOREIGN_AMOUNT = for_amount
FOREIGN_CURRENCY = 'USD'
LOCAL_CURRENCY = 'GPP'
TYPE_OF_RATE = 'M'
IMPORTING
LOCAL_AMOUNT = loc_ammount
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5.
The call calculates the "GPP" value of a given "USD" value based on TCURR's 'official averadge rate' of the current day. Sorry, I just translated the german term, but this is the rate, that is used for international money transfer.
Pls. remember that someone has to fill TCURR with correct values
If you find my answer useful, please don't forget the reward.
07-30-2007 1:01 PM
hi,
check this it may help you......
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
* CLIENT = 001
DATE = sy-datum
FOREIGN_CURRENCY = wa1-WAERS " here you need to declare your foreign currency i.e USD
LOCAL_CURRENCY = TCURR-FCURR
FOREIGN_AMOUNT = wa1-DMBTR " here you need to declare your amount field.
* RATE = tcurr-ukurs
TYPE_OF_RATE = 'M' " check this also the average rate
* READ_TCURR = 'X'
IMPORTING
EXCHANGE_RATE = tcurr-UKURS
* FOREIGN_FACTOR =
LOCAL_AMOUNT = wa1-TOTAL " this is the field where the converted amt has to be displayed.
* LOCAL_FACTOR =
* EXCHANGE_RATEX =
* FIXED_RATE =
* DERIVED_RATE_TYPE =
* 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.
Translate foreign currency amount to local currency
An amount in local currency is calculated from a specified foreign currency amount.
For this, you may either specify the translation rate manually (Parameter RATE)
or have the system determine it from table TCURR on the basis of the rate type, date and currency key.
Because the ratios for the units of the currencies involved in the translation are significant for this translation,
table TCURF is always read by the program, and there must be a valid entry there for the data specified. IF exchange rate fixing is defined for the exchange rate type TYPE_OF_RATE or an alternative exchange rate is defined for the currency pair, this information is transferred to the calling program.
When table TCURR is read, the foreign currency key is always taken as the first part of the key and the local currency as the second part.
hope this helps you.
regards,
Reshma
07-30-2007 1:02 PM
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = <date>
foreign_amount = <other amount>
foreign_currency = <other currency>
local_currency = <skk>
type_of_rate = <exchange rate>
IMPORTING
local_amount = <amount>
EXCEPTIONS
no_rate_found = 1
OTHERS = 2.
WRITE:/ amount.