SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Program Flow Logic → Exception Handling →Exceptions in ABAP Statements
Error situations,that occur during the execution of an ABAP statement raise exceptions. These exceptions are completely integrated into the exception concept and are triggered by the runtime environment. There are:
Each handleable exception is associated with a runtime error. The program terminates with this error if the exception is neither handled nor propagated to a caller. The keyword documentation lists the type of exceptions that can be raised for each statement.
For reasons of backward compatibility, handleable exceptions raised by many ABAP statements can be caught by using both TRY ... ENDTRY and the obsolete statement CATCH SYSTEM-EXCEPTIONS ... ENDCATCH. For this to be possible, the runtime error assigned to the exception class must be catchable. Within processing blocks, the two mechanisms prevent each other from handling exceptions. It is advisable to catch an exception between TRY ... ENDTRY using CATCH or to use the RAISING addition in the definition of the interface to propagate it to the caller. Catching exceptions using CATCH SYSTEM-EXCEPTIONS is not longer recommended.
Example
Unhandled exception
The following program lines produce the runtime error COMPUTE_INT_ZERODIVIDE because division by zero is invalid and this exception situation is not handled:
DATA result TYPE i.
result = 1 / 0.
Handling exceptions using exception classes
The above exception is represented by the exception class CX_SY_ZERODIVIDE, which is a subclass of the exception class CX_SY_ARITHMETIC_ERROR. This means that the exception can be handled as follows (the ERR_TEXT variable is passed the text 'Division by zero.'):
Handling exceptions as catchable runtime errors
The runtime error COMPUTE_INT_ZERODIVIDE is catchable and assigned to the exception group ARITHMETIC_ERRORS, which means it can also be handled using the obsolete statement CATCH SYSTEM-EXCEPTIONS.