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

Overflow error

aris_hidalgo
Contributor
0 Likes
3,781

Hello experts,

I am having an error with my report. Below is the error:

Overflow for arithmetical operation (type P) in program "ZFR_FOREX_REV_ACCTG "

Now, the variable that I am putting the amount is lv_amount which is type p decimals 2

with a length of 15. What can I do to make it fit? Thanks a lot guys and take care!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,875

You can handle this using TRY, ENDTRY.

data : w_error type ref to CX_SY_ARITHMETIC_OVERFLOW.

create w_error.

TRY.

do the sum total here.

CATCH (exception name for arithmetic overflow) into w_error.

call method get_text of w_error and display.

ENDTRY.

FOR data type P you can use a maximum length of 16, so increase the length of the TOTAL field to 16.

Message was edited by: Sharath kumar R

3 REPLIES 3
Read only

Former Member
0 Likes
1,876

You can handle this using TRY, ENDTRY.

data : w_error type ref to CX_SY_ARITHMETIC_OVERFLOW.

create w_error.

TRY.

do the sum total here.

CATCH (exception name for arithmetic overflow) into w_error.

call method get_text of w_error and display.

ENDTRY.

FOR data type P you can use a maximum length of 16, so increase the length of the TOTAL field to 16.

Message was edited by: Sharath kumar R

Read only

0 Likes
1,875

Or you can try with <b>TYPE F</b>. It will hold max of 9,9999999999999980E+15.

~thomas

Read only

0 Likes
1,875

Hi viray,

you can do this way..

PARAMETERS fact TYPE i. 
DATA: fact_save TYPE i, 
      res(16)  TYPE p. 
*** ARITHMETIC_ERRORS contains COMPUTE_BCD_OVERFLOW *** 
CATCH SYSTEM-EXCEPTIONS ARITHMETIC_ERRORS = 5. 
  res = fact_save = fact. 
  SUBTRACT 1 FROM fact. 
  DO fact TIMES. 
    MULTIPLY res BY fact. "<- COMPUTE_BCD_OVERFLOW 
    SUBTRACT 1 FROM fact. 
  ENDDO. 
ENDCATCH. 
IF sy-subrc = 5. 
  WRITE: / 'Overflow! Factorial of', fact_save, 
                               'cannot be calculated.'. 
ELSE. 
  WRITE: / 'Factorial of', fact_save, 'gives', res. 
ENDIF.

the same way you can handle your case.

Regards

vijay