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 (and 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 now obsolete. Each catchable runtime error is assigned an exception class instead, which is handled in aTRY
block. 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 are to be made handleable are no longer transformed 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
RAISE
orMESSAGE RAISING
as soon as an exception situation is detected. The caller of the procedure can use the additionEXCEPTIONS
of the statementCALL FUNCTION
or meth( ... ) to assign return codes for the system fieldsy-subrc
to 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-EXCEPTIONS
if class-based exceptions are handled there inTRY
blocks or are raised usingRAISE EXCEPTION
or the additionTHROW
in 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.