‎2009 Oct 26 6:58 AM
Hi all, I need to convert all amounts (sales and cost) to the currency specified on the selection screen. In selection screen i have 3 radio buttons with same group (USD, EUR, CAD), so what ever the sales order number(Select Options) or delivery number(Select Options) the user provide and the currency conversion radio button clicked the output should get converted according to the option he/she selected. Suppose if the amount is coming in USD and the USD radio button clicked then the same amount should get display, if the coming amount is USD and if you click the CAD then the amount should get converted to CAD and it should get displayed in the ALV output. here the coming currency may be anything like USD, EUR, CAD, CADN, etc... but i need to convert only to 3 type USD or EUR or CAD alone. Can anyone help me how to achieve it..... Thnkx n advance........
‎2009 Oct 26 7:02 AM
‎2009 Oct 26 7:02 AM
‎2009 Oct 26 7:28 AM
hi Soumya,
I have a doubt in the FM CONVERT_TO_FOREIGN_CURRENCY, ie., on the place of date and rate in the import parameter what value i should pass.
Can u plz explain this to me............
‎2009 Oct 26 7:46 AM
nothing needed to pass in the rate field
read the documentation of that FM.
‎2009 Oct 26 8:39 AM
Dear OP,
As a precaution before using the FM you should always check the table TCURR if the conv. rates for the currencies to be used are maintained. If so also check the exch. rate type (TCURR-KURST).
If you pass 'M' as default & your exch. rate type is say 'L1', then you wont get any result.
It is not encouraged to use the 'RATE' field, but the TYPE_OF_RATE is definitely important.
BR,
Suhas
‎2009 Oct 26 9:39 AM
Hi suhas,
Really the tips which u provided was very helpful. I will implement this and let u know if any doubts arises.
Thanks,
‎2009 Oct 26 12:47 PM
Hi suhas,
I tried to execute the function module as u mentioned but im getting the blank output.
For date i used sy-datum & it_tcurr-gdat
like this i followed but couldnt get the output.
Can u suggest me in this.
Thnks,
‎2009 Oct 26 12:50 PM
‎2009 Oct 28 4:41 AM
Hi all it has been solved........ Thanks alot guys...........
‎2009 Oct 26 7:03 AM
Hi,
Use the FM CONVERT_FOREIGN_TO_FOREIGN_CUR to do the currency conversions.
Vikranth
‎2009 Oct 26 7:10 AM
Hi Sowmay & Vikranth,
Thanks for your quick response.
I found the FM convert_to_local_currency----> wt is the use of this function module........
and also i found a code for the conversion is
data: w_edate type sy-datum.
LOOP AT i_info.
* Do requested currency conversion.
w_excrate = 1.
IF P_EUR EQ 'X'. "checking radio button if EUR clicked
LOOP AT i_curr
WHERE fcurr EQ i_info-waerk
AND tcurr EQ 'EUR'.
CONVERT INVERTED-DATE i_curr-gdatu INTO DATE w_edate.
IF i_info-mbdat GE w_edate.
w_excrate = 0 - i_curr-ukurs.
EXIT.
ENDIF.
ENDLOOP.
ELSEIF P_USD EQ 'X'. "checking radio button if USD clicked
LOOP AT i_curr
WHERE fcurr EQ i_info-waerk
AND tcurr EQ 'USD'.
CONVERT INVERTED-DATE i_curr-gdatu INTO DATE w_edate.
IF i_info-mbdat GE w_edate.
w_excrate = 0 - i_curr-ukurs.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
i_info-netpr = i_info-netpr / w_excrate. "Output to get display after conversion
here they are doing some calculation........ i have doubt like after these code i will be getting a converted amount..... whether this amount is equal to the amount which we get in the function module??????
can u plz suggest me..........
‎2009 Oct 26 7:11 AM
‎2009 Oct 26 7:19 AM
no, if i connect to their server then my internet connection gets blocked.........
k i ll use the fm's which u specified & i let u know
‎2009 Oct 26 7:38 AM
Hi,
you can check the radio button and then perform the FM to convert..
eg..
if rad1 = 'X'.
perform convert_currency using USD...
elseif rad2 = 'X'.
perform convert_currency using EUR...
elseif rad3 = 'X'.
perform convert_currency usng ...CAD
endif.
use FM as mentioned in the above replies..
Thanks
‎2009 Oct 26 8:25 AM
Hello Vichu,
The below piece of code may be helpful to you.
When you loop, create a subroutine.
Ex:
if USD is selected.
perform convert_currency.
elseif EUR is selected.
perform convert_currency.
elseif...
perform convert_currency.
endif..
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
client = sy-mandt
date = sy-datum
foreign_amount = <Sales Order Amount>
foreign_currency = <Actual Currency>
local_currency = <Currency in which you want to convert>
rate = 0
type_of_rate = 'EURX' "'M' -> Get this rate information from the Functional guys.
read_tcurr = 'X'
IMPORTING
local_amount = <Converted Amount>
EXCEPTIONS
no_rate_found = 1
...........
...........
derived_2_times = 5
OTHERS = 6.
Let me know if you need more details.
Regards,
Shiva.