Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Currency Conversion

Former Member
0 Likes
1,602

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........

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,531

use FM CONVERT_TO_FOREIGN_CURRENCY

14 REPLIES 14
Read only

Former Member
0 Likes
1,532

use FM CONVERT_TO_FOREIGN_CURRENCY

Read only

0 Likes
1,531

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............

Read only

0 Likes
1,531

nothing needed to pass in the rate field

read the documentation of that FM.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,531

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

Read only

0 Likes
1,531

Hi suhas,

Really the tips which u provided was very helpful. I will implement this and let u know if any doubts arises.

Thanks,

Read only

0 Likes
1,531

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,

Read only

0 Likes
1,531

Did you check this CONVERT_FOREIGN_TO_FOREIGN_CUR ?

Read only

0 Likes
1,531

Hi all it has been solved........ Thanks alot guys...........

Read only

Former Member
0 Likes
1,531

Hi,

Use the FM CONVERT_FOREIGN_TO_FOREIGN_CUR to do the currency conversions.

Vikranth

Read only

0 Likes
1,531

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..........

Read only

0 Likes
1,531

have you tried the FMs we have proposed?

Read only

0 Likes
1,531

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

Read only

Former Member
0 Likes
1,530

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

Read only

Former Member
0 Likes
1,530

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.