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 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 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
RAISE
orMESSAGE RAISING
as soon as an exception situation is recognized. The procedure caller 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.