Error situations, that occur during the execution of an ABAP statement, lead to exceptions. These exceptions are completely integrated in the exception concept and are triggered by the runtime environment. There are:
Every exception that can be handled is assigned a runtime error, with which the program terminates if the exception is neither handled nor propagated to a caller. The key word documentation lists the type of exceptions that can occur for each statement.
For reasons of backward compatibility, exceptions that occur with many ABAP statements can be caught with TRY ... ENDTRY as well as CATCH SYSTEM-EXCEPTIONS ... ENDCATCH. For this to be the case, the runtime error assigned to the exception class must be catchable. Within a processing block, the two mechanisms exclude themselves from the handling of exceptions. We advise you, either to catch a runtime error between TRY ... ENDTRY using CATCH, or propagate it to the caller using the RAISINGaddition in the definition of the interface. From Release 6.10 onwards you should avoid catching using CATCH SYSTEM-EXCEPTIONS.
The following program lines cause the runtime error COMPUTE_INT_ZERODIVIDE, because the system cannot handle dividing by zero:
data RESULT type I.
RESULT = 1 / 0.
The above exception is represented by the exception classCX_SY_ZERODIVIDE, which is a subclass of the exception class CX_SY_ARITHMETIC_ERROR. Therefore the exception can be handled as follows (The ERR_TEXT variable receives the text 'Division by zero.'):
data MYREF type ref to CX_SY_ARITHMETIC_ERROR.
data ERR_TEXT type STRING.
data RESULT type I.
try.
RESULT = 1 / 0.
catch cx_sy_arithmetic_error into MYREF.
ERR_TEXT = MYREF->GET_TEXT( ).
endtry.
Because the runtime error COMPUTE_INT_ZERODIVIDE is catchable and assigned to the exception group ARITHMETIC_ERRORS, it can also be handled as follows:
data RESULT type I.
catch system-exceptions ARITHMETIC_ERRORS = 4.
RESULT = 1 / 0.
endcatch.
if SY-SUBRC = 4.
...
endif.