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

Runtime Error : Overflow

Former Member
0 Likes
2,340

Hello All,

I am using the FM READ_EXCHANGE_RATE to get the Exchange rate


data : zkursf_str(10).
if sy-subrc eq 0.
            CALL FUNCTION 'READ_EXCHANGE_RATE'
              EXPORTING
                DATE                    = z_header-budat
                FOREIGN_CURRENCY        = z_header-waers
                LOCAL_CURRENCY          = temp_loc_cur1
                TYPE_OF_RATE            = 'M'
          IMPORTING
                EXCHANGE_RATE           = zkursf_str
*           FOREIGN_FACTOR          =
*           LOCAL_FACTOR            =
*           VALID_FROM_DATE         =
*           DERIVED_RATE_TYPE       =
*           FIXED_RATE              =
*           OLDEST_RATE_FROM        =
                      .
            IF SY-SUBRC eq 0.
              move zkursf_str to z_header-kursf. <-----
            else.
              message S000 with 'No Exchange Rate found '.
            ENDIF.
          endif.
        endif.

I a Particular case the Exchange rate (KURSF) obtained is '100000' and when the value is moved to Z_header-kursf (defined as BKPF-KURSF) i receive the 'Overflow when converting from 100000'.

Could any one point the error and how to rectify this .

Regards,

- Sravan

1 ACCEPTED SOLUTION
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,730

Hi,

I hope the error is because while you move to z_header-kursf which is of type BKPF-KURSF,it is internally calling the conversion exit 'CONVERSION_EXIT_EXCRT_INPUT' at the domain level{Check the BKPF-KURSF by double clicking).In this FM,if you look at the source code,it is calling 'CONVERT_RATE_INPUT'.This needs the input to be of the format 9,999.99999.

So instead of writing the line

move zkursf_str to z_header-kursf.

Use the FM 'CONVERSION_EXIT_EXCRT_OUTPUT' to change the zkursf_str to this format.

CALL FUNCTION 'CONVERSION_EXIT_EXCRT_OUTPUT'

EXPORTING

input = zkursf_str

IMPORTING

OUTPUT = z_header-kursf.

Kindly reward points if it helps.

Message was edited by: Jayanthi Jayaraman

10 REPLIES 10
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,730

Hi,

Change the declaration

data : zkursf_str(10).

to

data zkursf_str(14).

Since the BKPF-KURSF is of output length 14.

Kindly reward points by clikcing the star on the left of reply,if it helps.

Read only

0 Likes
1,730

Hello Jayanthi,

Thanks for the post.

I modified the zkursf_str to 14 but still the same error.

I even declared the zkursf_str as bkpf-kursf when compiling i receive the error 'ZKURSF_STR must be a Character type data object (C, N, D, T or String)'.

Regards,

- Sravan

Read only

Former Member
0 Likes
1,730

Sravan,

Why don't you refer that field to a data element which has the maximum size?

Regards,

Ravi

Read only

Former Member
0 Likes
1,730

Hello Sravan,

What is the type for zkursf_str? is it same as receiving field?

Read only

Former Member
0 Likes
1,730

Hi Sravan,

How did you define the variable

<b>z_header-kursf</b>

<b>The definition of KURSF is DEC of Length 9 with Output Length 12.</b>

Also of DEC data type.

Regards,

Wenceslaus.

Read only

Former Member
0 Likes
1,730

Hi,

Try this..

CALL FUNCTION 'READ_EXCHANGE_RATE'

EXPORTING

DATE = z_header-budat

FOREIGN_CURRENCY = z_header-waers

LOCAL_CURRENCY = temp_loc_cur1

TYPE_OF_RATE = 'M'

IMPORTING

EXCHANGE_RATE = <b>z_header-kursf</b>

  • FOREIGN_FACTOR =

  • LOCAL_FACTOR =

  • VALID_FROM_DATE =

  • DERIVED_RATE_TYPE =

  • FIXED_RATE =

  • OLDEST_RATE_FROM =

.

Regards,

Shashank

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,731

Hi,

I hope the error is because while you move to z_header-kursf which is of type BKPF-KURSF,it is internally calling the conversion exit 'CONVERSION_EXIT_EXCRT_INPUT' at the domain level{Check the BKPF-KURSF by double clicking).In this FM,if you look at the source code,it is calling 'CONVERT_RATE_INPUT'.This needs the input to be of the format 9,999.99999.

So instead of writing the line

move zkursf_str to z_header-kursf.

Use the FM 'CONVERSION_EXIT_EXCRT_OUTPUT' to change the zkursf_str to this format.

CALL FUNCTION 'CONVERSION_EXIT_EXCRT_OUTPUT'

EXPORTING

input = zkursf_str

IMPORTING

OUTPUT = z_header-kursf.

Kindly reward points if it helps.

Message was edited by: Jayanthi Jayaraman

Read only

0 Likes
1,730

Hello Jayanthi,

Thank you, for providing the pointer.

I have rewarded and after slight modification to existing code the FM worked (Completly overlooked the EXIT)


          select single waers from T001 into temp_loc_cur1
          where bukrs = z_header-bukrs.           "Currency Key

          if sy-subrc eq 0.
            CALL FUNCTION 'READ_EXCHANGE_RATE'
              EXPORTING
                DATE                    = z_header-budat
                FOREIGN_CURRENCY        = z_header-waers
                LOCAL_CURRENCY          = temp_loc_cur1
                TYPE_OF_RATE            = 'M'
          IMPORTING
                EXCHANGE_RATE           = zkursf_str
*           FOREIGN_FACTOR          =
*           LOCAL_FACTOR            =
*           VALID_FROM_DATE         =
*           DERIVED_RATE_TYPE       =
*           FIXED_RATE              =
*           OLDEST_RATE_FROM        =
                      .
            IF SY-SUBRC eq 0.
              CALL FUNCTION 'CONVERSION_EXIT_EXCRT_OUTPUT'
                EXPORTING
                  INPUT  = zkursf_str
                IMPORTING
                  OUTPUT = zkursf_str1.
              .
              move zkursf_str1 to z_header-kursf.
            else.
              message S000 with 'No Exchange Rate found '.
            ENDIF.
          endif.
        endif.

Thank you.

- Sravan

Read only

Former Member
0 Likes
1,730

Hi Sravan,

Please try this.

DATA: <b>KURS LIKE TCURR-UKURS</b>.

CALL FUNCTION 'READ_EXCHANGE_RATE'

EXPORTING

DATE = SY-DATUM

FOREIGN_CURRENCY = z_header-waers

LOCAL_CURRENCY = temp_loc_cur1

TYPE_OF_RATE = 'M'

IMPORTING

EXCHANGE_RATE = <b>KURS</b> EXCEPTIONS

NO_RATE_FOUND = 1

NO_FACTORS_FOUND = 2

NO_SPREAD_FOUND = 3

OTHERS = 4.

Regards,

Kaushal

Read only

Former Member
0 Likes
1,730

Hello Sravan,

As I can c initally u had declared zkursf_str as 10 chara and then u have declared it as 14. What u need to do is make both zkursf_str and z_header-kursf same type. so if u want a larger declaration say then u can declare it as

zkursf_str type ACC_BEARZEIT

z_header-kursf type ACC_BEARZEIT.