2012 Jan 22 6:51 AM
Is there any way to catch this exception, without checking or changing numerical value.
CATCH SYSTEM-EXCEPTIONS
convt_no_number = 1
convt_overflow = 2
bcd_field_overflow = 3
bcd_overflow = 4.
DO 10000000000000 TIMES. "<<--Runtime Error-BCD_OVERFLOW (Overflow during an arithmetic operation)
write:/ sy-index.
ENDDO.
ENDCATCH.
Regards
Sain
2012 Jan 22 8:59 AM
CX_SY_ARITHMETIC_OVERFLOW
it is a catchable exception. put it in a try catch block and this exception class will catch your error
2012 Jan 22 9:33 AM
TRY .
DO 10000000000000 TIMES.
write:/ sy-index.
ENDDO.
CATCH CX_SY_ARITHMETIC_OVERFLOW."CX_SY_CONVERSION_OVERFLOW.
ENDTRY.
Still same error.
My main intension is to solve this with exception handling.
2012 Jan 22 9:50 AM
try this...
data: p1 type p.
TRY.
p1 = 10000000000000.
DO p1 TIMES.
write:/ sy-index.
ENDDO.
CATCH cx_sy_arithmetic_error. "outside value range
ENDTRY.
2012 Jan 22 9:59 AM
oopsi
data: p1 type p.
TRY.
p1 = 10000000000000.
DO p1 TIMES.
write:/ sy-index.
ENDDO.
CATCH CX_SY_ARITHMETIC_OVERFLOW. "try both the examples
ENDTRY.
2012 Jan 22 10:28 AM
Dear Mishra,
Thanks for answer.
Try.
p1 = 10000000000000.
this one will work for sure. But I am trying to catch error resulting in a time consuming loop.
2012 Jan 22 10:44 AM
ook.. got your point.
CATCH SYSTEM-EXCEPTIONS ARITHMETIC_ERRORS = 5.
DO 10000000000000 TIMES. "<<--Runtime Error-BCD_OVERFLOW (Overflow during an arithmetic operation)
write:/ sy-index.
ENDDO.
ENDCATCH.
ENDCATCH.
IF sy-subrc = 5.
wrie 'overflow'.
endif.
2012 Jan 22 10:51 AM
if this does not work then pass the sy-index + 1 to an integer variable before the enddo.. this should definitely work.
2012 Jan 22 11:23 AM
Thanks for quick reply Mishra.
But unfortunately it didn't work.
2012 Jan 22 9:51 PM
Hi,
As explained in the ABAP documentation, the number of iterations has to match a I type (integer up to 2 billion). Note: SY-INDEX is also an integer.
What is fun here is that the ABAP runtime environment doesn't apply the CATCH to the conversion overflow when it's done in the DO statement.
If you do this, the exception is handled correctly:
data pack type p length 10 DECIMALS 0.
data integer type i.
CATCH SYSTEM-EXCEPTIONS
convt_no_number = 1
convt_overflow = 2
bcd_field_overflow = 3
bcd_overflow = 4.
pack = 10000000000000.
integer = pack. "<==== Here exception BCD_OVERFLOW occurs and is handled by the CATCH
DO integer TIMES.
write:/ sy-index.
ENDDO.
ENDCATCH.
Now, if you want to do a big big loop, you have to accommodate with the system's restriction by using a nested loop:
DATA pack TYPE p LENGTH 8 DECIMALS 0. "up to 15 digits
DO 1000000 TIMES.
DO 10000000 TIMES.
ADD 1 TO pack.
write:/ pack.
ENDDO.
ENDDO.
Sandra