on 2015 Apr 07 1:15 AM
Hi ABAP Gurus,
I wanted to convert my all currencies to USD, I have exchange rates in TCURR Table already.
I have used below code to call FM and used code for key figure (0DEB_CRE_LC) but the out values are become a ZERO.
DATA: L_KURST type TCURR-KURST, "exchg.rate type (M or variant)
L_CURR_RATE type TCURR-UKURS, "exchange rate value
L_FC type TCURR-FCURR, " From currency
L_TC type TCURR-TCURR, " To currency
L_FF type TCURR-FFACT,
L_TF type TCURR-TFACT,
L_FA(16) type p.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = SY-DATUM "currency date
FOREIGN_AMOUNT = L_FA "trans. currency amount
FOREIGN_CURRENCY = L_FC "trans. currency code
LOCAL_CURRENCY = 'USD' "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 = L_FF
LOCAL_AMOUNT = L_FA
LOCAL_FACTOR = L_TF
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
OTHERS = 5.
* RESULT = 100.
Could you please check and let me know if am doing wrong.
Regards,
Vishu
Request clarification before answering.
Hello,
There are two methods to convert the currency. Mentioned two methods below.
You can follow either one.
1. Same way you did. Please check the parameters once again. below is my code
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
client = sy-mandt
date = sy-datum
foreign_amount = l_wrbtr
foreign_currency = hdrcurrency
local_currency = 'USD'
* RATE = 0
* TYPE_OF_RATE = 'M'
* READ_TCURR = 'X'
IMPORTING
* EXCHANGE_RATE =
* FOREIGN_FACTOR =
local_amount = l_usd_amount
* 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 EQ 0.
2. Multiply the Foreign amount with the exchange rate, then you will get the converted USD amount.. Recently I tried this , it works. Use FM below, it returns the latest exchange rate from TCURR table.
data: l_rate TYPE UKURS_CURR.
CALL FUNCTION 'READ_EXCHANGE_RATE'
EXPORTING
CLIENT = SY-MANDT
date = sy-datum
foreign_currency = l_waers
local_currency = 'USD'
TYPE_OF_RATE = 'M'
* EXACT_DATE = ' '
IMPORTING
EXCHANGE_RATE = l_rate
* FOREIGN_FACTOR =
* LOCAL_FACTOR =
* VALID_FROM_DATE =
* DERIVED_RATE_TYPE =
* FIXED_RATE =
* OLDEST_RATE_FROM =
* EXCEPTIONS
* NO_RATE_FOUND = 1
* NO_FACTORS_FOUND = 2
* NO_SPREAD_FOUND = 3
* DERIVED_2_TIMES = 4
* OVERFLOW = 5
* ZERO_RATE = 6
* OTHERS = 7
Now multiply the rate with the amount.
itab-usd_amt = l_rate * itab-foreign_amount.
You can cross verify the result in Google .
please let me know if any questions.
Thanks
AV
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I can see that FM is called immediately after definition of data. So no values for FOREIGN_AMOUNT, FOREIGN_CURRENCY,TYPE_OF_RATE is getting passed. Make sure that you pass some values into it.
RATE is optional. So you can either pass some value or comment it out.
Thanks,
Ashok Veer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ashok, Right seems the above parameters are not getting any values as my key figure values are become a zero in SAP BW after DTP ran.
But i need to confirm one thing. If you see in SS, We have 0FISCAL YEAR/PERIOD as 2015007 but actually i have to treat it as 2015.01. whether it will cause to my issue.
I have exchange rates for 2015.01.
Could you please let me know where was the problem occurs?
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.