ABAP Keyword Documentation → ABAP - Reference → Program Flow Logic → Exception Handling
Exceptions Before Class-Based Exceptions
Exceptions are class-based. Before the introduction of exception classes, there were the following types of exceptions:
- Exception situations detected by the system whose causes could be handled effectively by the program, raised
catchable runtime errors that could be handled
by the statement
CATCH SYSTEM-EXCEPTIONS. Catchable runtime errors are obsolete. An exception class is assigned to each catchable runtime error, to be handled in a
TRYblock. Conversely, not all predefined, class-based exceptions are assigned to a catchable runtime error. No new catchable runtime errors are created, and existing runtime errors that should be made ready for handling are no longer converted to catchable runtime errors. Instead, exception classes are assigned to them.
- Self-defined handleable exceptions were allowed only in the interfaces of function modules and methods. These types of exceptions can be raised within the
procedure by the statement
MESSAGE RAISINGas soon as an exception situation is recognized. The procedure caller can use the addition
EXCEPTIONSof the statement
CALL FUNCTIONor meth( ... ) to assign return codes for the system field
sy-subrcto the exceptions the caller wants to handle and evaluate them after the call. However, this is not true exception handling in the sense of reacting to an event.
Other versions: 7.31 | 7.40 | 7.54
Interaction of the Exception Concepts
The class-based exceptions replace and enhance the previous concepts in full. Class-based exceptions can be raised and handled in all ABAP contexts (programs, processing blocks). In particular, all previously catchable runtime errors can be handled as class-based exceptions, with the previous exception groups being mapped to shared superclasses. For reasons of downward-compatibility, the catchable runtime errors and the non-class-based exceptions defined in the interfaces of methods and function modules have not been abolished, but their use has been restricted as follows:
- Within a processing block, only one kind of exception can be raised.
- Within a procedure interface, the declaration of class-based exceptions and the definition of non-class-based exceptions exclude one another.
- Within a processing block, catchable runtime errors cannot be caught using
CATCH SYSTEM-EXCEPTIONSif class-based exceptions are handled there in
TRYblocks or are raised using
RAISE EXCEPTIONor the addition
THROWin a conditional expression. Instead, catchable runtime errors must be caught when handling the associated class-based exception.
For reasons of interoperability, class-based exceptions can be handled within a processing block and return codes of function modules and methods evaluated there using non-class-based exceptions.