02-04-2015 1:04 PM
Hi experts,
i am trying to use the FM covert to local curreny to convert currency to USD. But the local amount shows up 100 times the actual. Please suggest.
Below is my code.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = re_outtab_purchdoc-bedat
foreign_amount = re_outtab_purchdoc-netwr
foreign_currency = re_outtab_purchdoc-waers
local_currency = LV_CURR
* RATE = 0
* TYPE_OF_RATE = 'M'
* READ_TCURR = 'X'
IMPORTING
* EXCHANGE_RATE =
* FOREIGN_FACTOR =
local_amount = re_outtab_purchdoc-NETVALC
* 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.
02-04-2015 1:16 PM
Hi,
try this.......
CALL FUNCTION 'READ_EXCHANGE_RATE'
EXPORTING
date = sy-datlo
foreign_currency = foreign_currency
local_currency = lv_curr
type_of_rate = 'P' "Standard translation for cost planning
IMPORTING
exchange_rate = l_kursf
EXCEPTIONS
error_message = 1.
CALL FUNCTION 'CURRENCY_AMOUNT_DISPLAY_TO_SAP'
EXPORTING
currency = foreign_currency
amount_display = foreign_amount
IMPORTING
amount_internal = converted_amount
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = re_outtab_purchdoc-bedat
foreign_amount = converted_amount
foreign_currency = foreign_currency
local_currency = LV_CURR
rate = l_kursf
type_of_rate = 'P' "Standard translation for cost planning
date = sy-datlo
IMPORTING
local_amount = lv_amount
CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_DISPLAY'
EXPORTING
currency = LV_CURR
amount_internal = lv_amount
IMPORTING
amount_display = lv_amount "FINAL AMOUNT Converted
Thanks,
Sharath
02-04-2015 1:42 PM
Hi,
i tried it in this way:
and it works. Have also a look into table TCURR.
Regards, Dieter
02-06-2015 12:38 PM
Hi,
Can you try the same with local currency = 'KWD'?
Please observe the o/p.
100 USD = 29.48 KWD
Regards
Sreekanth
02-04-2015 1:45 PM
Hi,
Try,
CALL FUNCTION 'CONVERT_AMOUNT_TO_CURRENCY'
Hope it helpful.
Regards,
Venkat.
02-05-2015 8:38 AM
Local amount is 100x more then it should be or its just appear on output 100x more? Because i had this problem with CURR 22 5 - in debug mode it had correct value, but in ALV output it was 100x more. My solution(and I admitt - not very good) was to add one more CURR field for output with 13 length 5 decimals.
02-06-2015 8:27 AM
local amounts are appearing 100 times more. eg: instead of 1 USD it appears as 100 USD
02-06-2015 8:38 AM
Try to use for output variable:
DATA: lv_out_amout TYPE p LENGTH 13 DECIMALS 5.
lv_out_amount = re_outtab_purchdoc-netwr
02-05-2015 8:55 AM
Hi ,
What 's your local currency. Some small currency will be enlarge when it display.
pls check first.
Hope this will help you..
02-06-2015 8:26 AM
02-06-2015 8:34 AM
02-06-2015 8:38 AM
TCURR is having the exchange rate for the currencies which i am trying to convert. is there anything else that i have to look into TCURR?
02-06-2015 8:39 AM
hi lavanya,
You have to use fm 'CONVERSION_EXIT_EXCRT_OUTPUT'
to get correct exchange rate
CALL FUNCTION 'CONVERSION_EXIT_EXCRT_OUTPUT'
EXPORTING
input = IT_OUTPUT-EXR
IMPORTING
OUTPUT = ex_rate.
ex_rate will have correct exchange rate.
02-06-2015 8:44 AM
hi,
may i know what is it_output-exr
and also should i use this FM before CONVERT_TO_LOCAL_CURRENCY' or after?
02-06-2015 8:58 AM
it_output-exr or exr is the exchange rate.
add in your code like this
IMPORTING
EXCHANGE_RATE = exr
* FOREIGN_FACTOR =
local_amount = re_outtab_purchdoc-NETVALC
* LOCAL_FACTOR =
after this (CONVERT_TO_LOCAL_CURRENC) use fm 'CONVERSION_EXIT_EXCRT_OUTPUT'
and check the values ex_rate.
02-06-2015 9:13 AM
thanks for your response. but my doubt is we are only getting the exc rate but how is the currency getting processed here?
i got a dump when i tried the above FM
02-06-2015 9:33 AM
please give some values(actual parameters each one) so that it can be tried as per your requirement.
02-06-2015 10:15 AM
in the standard ME2N transaction i have implemented the below enhancement
DATA: COMM_CUR TYPE EKKO-WAERS,
LV_CURR TYPE EKKO-WAERS.
* Import common currency entered on the selection-screen
IMPORT COMM_CUR TO LV_CURR FROM MEMORY ID 'ZME2N'.
re_outtab_purchdoc-WAERSC = LV_CURR.
* If the common currency on the selection-screen is not same as the currency in PO
* then do the currency conversion
if re_outtab_purchdoc-waers ne LV_CURR and not lv_curr is initial.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = re_outtab_purchdoc-bedat
foreign_amount = re_outtab_purchdoc-netwr
foreign_currency = re_outtab_purchdoc-waers
local_currency = LV_CURR
* RATE = 0
* TYPE_OF_RATE = 'M'
* READ_TCURR = 'X'
IMPORTING
* EXCHANGE_RATE =
* FOREIGN_FACTOR =
local_amount = re_outtab_purchdoc-NETVALC
* 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.
ELSE.
re_outtab_purchdoc-NETVALC = re_outtab_purchdoc-netwr.
endif.
now because of this enhancement value re_outtab_purchdoc-NETVALC is coming 100 time more
i do not understand where is the flaw.
please suggest
02-06-2015 11:01 AM
please give the values of
1) LV_CURR.
2) re_outtab_purchdoc-bedat
3) re_outtab_purchdoc-netwr
4) re_outtab_purchdoc-waers
you can get these values while debug
02-06-2015 12:12 PM
1) LV_CURR.- USD
2) re_outtab_purchdoc-bedat 20150204
3) re_outtab_purchdoc-netwr 4.06
4) re_outtab_purchdoc-waers XAF
02-06-2015 5:30 PM
can you share the result after you run this piece of code:
DATA: XRATE TYPE F,
FAMT TYPE P DECIMALS 2,
FFACT TYPE F,
LFACT TYPE F.
PARAMETERS: FCURR LIKE TCURC-WAERS,
LCURR LIKE TCURC-WAERS,
LAMT TYPE P DECIMALS 2.
CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
EXPORTING
DATE = SY-DATUM
FOREIGN_CURRENCY = FCURR
LOCAL_AMOUNT = LAMT
LOCAL_CURRENCY = LCURR
IMPORTING
EXCHANGE_RATE = XRATE
FOREIGN_AMOUNT = FAMT
FOREIGN_FACTOR = FFACT
LOCAL_FACTOR = LFACT
.
IF SY-SUBRC EQ 0.
WRITE: / LAMT, 'CONVERTED FROM', LCURR, 'TO', FCURR, 'IS:', FAMT.
WRITE: / 'EXCHANGE RATE: ', XRATE,
/ 'FOREIGN FACTOR:', FFACT,
/ 'LOCAL FACTOR:', LFACT.
ELSE.
WRITE: 'UNABLE TO CONVERT'.
ENDIF.
02-06-2015 9:13 AM
Hi Lavanya,
Unchecked the fixed point arithmetic in program attribute.
And re_outtab_purchdoc-NETVALC should be a variable with 2 decimal places.
Regards
Sreekanth
02-06-2015 9:22 AM
Better to do this in a separate subroutine pool program and create a form(refer attachment).
call this form from your program as shown..
PERFORM currency_to_local(zsmm_create_fcurr_to_lcurr)
USING fc_waers
lc_waers
netpr
kdatu
kkurs
kufix.
02-06-2015 10:20 AM
02-06-2015 10:26 AM
Its possible.
se38->create a program of type subroutine pool(say zsmm_create_fcurr_to_lcurr ) and create the form as I said. Remember to uncheck Fixed point arithmetic in this subroutine pool.
Then call the form.
PERFORM currency_to_local(zsmm_create_fcurr_to_lcurr)
USING fc_waers
lc_waers
netpr
kdatu
kkurs
kufix.
What is the type of re_outtab_purchdoc?
02-06-2015 9:30 AM
Hi,
did you try my example esp. the declaration of the variables?
Can you please Show your declarations.
Regards, Dieter