‎2006 Aug 14 6:14 AM
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!
‎2006 Aug 14 6:32 AM
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
‎2006 Aug 14 6:32 AM
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
‎2006 Aug 14 6:36 AM
Or you can try with <b>TYPE F</b>. It will hold max of 9,9999999999999980E+15.
~thomas
‎2006 Aug 14 6:45 AM
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