‎2005 Nov 11 10:36 AM
Hi developers, i try to convert from a currency to anothr using the following code:
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = SY-DATUM
FOREIGN_AMOUNT = P_PREZZO
FOREIGN_CURRENCY = F_VBAK-WAERK
LOCAL_CURRENCY = V_DIVISA_NEGOZIO
rate = TCURR-UKURS
TYPE_OF_RATE = 'YSEV'
READ_TCURR = 'X'
IMPORTING
LOCAL_AMOUNT = V_FOREIGN_AMOUNT.
but the result i get back seems to be 100 times greater than i expected, as decimals are included in the integer part of the value.
Have you got any suggestions?
Thankx a lot
‎2005 Nov 11 10:47 AM
Hi,
I think you have to check your TYPE_OF_RATE.
LOCAL_CURRENCY give 'WAERS'(assign directly) AND JUST CHECK IT UP.
Thanks.
Message was edited by: Deepak333 k
Message was edited by: Deepak333 k
‎2005 Nov 11 10:47 AM
Hi,
I think you have to check your TYPE_OF_RATE.
LOCAL_CURRENCY give 'WAERS'(assign directly) AND JUST CHECK IT UP.
Thanks.
Message was edited by: Deepak333 k
Message was edited by: Deepak333 k
‎2005 Nov 11 10:50 AM
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.
reward points for helpfull answers and close the thread if your question is solved.
regards,
venu.
‎2005 Nov 11 10:51 AM
Hi!
Are both amount fields defined as currency field with decimal 2 (e.g. konp-kbetr)? Internally 2 decimals are added anyway, from here your factor 100 comes - it's just a question how don't get mixed up with different field definitions.
Regards,
Christian
‎2005 Nov 11 12:32 PM
Hi,
Here is the sample code.
CALL FUNCTION 'CONVERT_AMOUNT_TO_CURRENCY'
EXPORTING
date = sy-datum
foreign_currency = 'USD'
foreign_amount = '2000.00'
local_currency = 'EUR'
IMPORTING
local_amount = amount.
Hope this helps.If so,kindly reward points.
‎2005 Nov 11 1:01 PM
Hi,
Please look in to tcurx table to know no of decimals
defined for currency.
Regards
Amole
‎2005 Nov 11 2:19 PM
Hi Domenico.
It looks like your local curency, has 0 decimal places - you shoul look for this information in transaction OY04 (IMG- general settings-Currencies).
If your currency is in this table - so it has no decimals places and as resul of conversion you got X100.
Regards Vitali
‎2005 Nov 11 2:31 PM
After that function call use write with currency option it will give the exact result.
write p_prezzo into new_variable with currenty f_vbak-werk.
Cheers,
Satya