Application Development 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: 

FM CONVERT_TO_LOCAL_CURRENCY

Former Member
0 Kudos

Hi all.

I'm using FM CONVERT_TO_LOCAL_CURRENCY in a program, but it doesn't work. My code is:

DATA: aux(200).


  CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

    EXPORTING

*     CLIENT                  = SY-MANDT

      date                    = sy-datum

      foreign_amount          = p_zovh_overhead

      foreign_currency        = zovh-twaer

      local_currency          = 'EUR'

     RATE                    = 0

     TYPE_OF_RATE            = 'M'

     READ_TCURR              = 'X'

   IMPORTING

*     EXCHANGE_RATE           =

*     FOREIGN_FACTOR          =

     LOCAL_AMOUNT            = AUX

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

In variable AUX any value is get. I have tested this FM in sm37 and it doesn't work.

Can you help me? Thanks a lot.

Marta.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Please change the type of AUG  to the same type of

p_zovh_overhead.

I used in the following way:

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

           EXPORTING

             date             = sy-datum

             foreign_amount   = ekpo-brtwr

             foreign_currency = eine-waers

             local_currency   = 'EUR'

           IMPORTING

             local_amount     = ekpo-brtwr

           EXCEPTIONS

             no_rate_found    = 1

             overflow         = 2

             no_factors_found = 3

             no_spread_found  = 4

             OTHERS           = 5.

         IF sy-subrc NE 0.

           CLEAR ekpo-brtwr.

         ENDIF.



4 REPLIES 4

Former Member
0 Kudos

Hi,

Please change the type of AUG  to the same type of

p_zovh_overhead.

I used in the following way:

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

           EXPORTING

             date             = sy-datum

             foreign_amount   = ekpo-brtwr

             foreign_currency = eine-waers

             local_currency   = 'EUR'

           IMPORTING

             local_amount     = ekpo-brtwr

           EXCEPTIONS

             no_rate_found    = 1

             overflow         = 2

             no_factors_found = 3

             no_spread_found  = 4

             OTHERS           = 5.

         IF sy-subrc NE 0.

           CLEAR ekpo-brtwr.

         ENDIF.



ThomasZloch
Active Contributor
0 Kudos

It is used in the standard code and in customer developments all over the world, so it does work, provided the input is correct and conversion rates are maintained.

Since many of the parameters are not typed, you'll have to scroll your screen all the way to the right in SE37 testing in order the see the returned values.

Any reason why you declare AUX as character length 200 instead of a proper amount field?

Thomas

Former Member
0 Kudos

hi marta,

parameter lc_amount type p decimal 2.

DATA: v_amount TYPE p DECIMALS 2.

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

     EXPORTING

          date             = sy-datum

          foreign_currency = 'INR'

          local_amount     = lc_amount

          local_currency   = 'USD'

     IMPORTING

          foreign_amount   = v_amount

     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.

  WRITE: / 'US dollar to Indian rupees - ', v_amount.

ENDIF.

Hope this will work

Thanks

Anshul

0 Kudos

Hi all.

Thanks a lot. The problem was type of AUX variable. FM works in the program. I don't know why FM doesn`t work when I executed it from sm37, but program works and it is good.

Thanks again.