ABAP Keyword Documentation →  ABAP − Reference →  Program Flow Logic →  Exception Handling → 

Class-Based Exceptions

Class-based exceptions are realized as instances of exception classes. Exception classes are either predefined globally in the system or can be defined by the user (globally or locally). Class-based exceptions are raised either by the ABAP runtime environment or by a program.

When an exception is raised, an exception object can be created, whose attributes contain information about the error situation. A class-based exception can be handled in a TRY control structure. The TRY block defines a protected area, whose exceptions can be handled in subsequent CATCH blocks. The statement RETRY enables a complete TRY block to be repeated after an exception. Because all exception classes are subclasses of common superclasses, the associated exceptions can be handled at the same time by handling the respective superclass. The system propagates the exception object or the class-based exception until the exception is handled or an interface is violated.

There are two different exception handling cases:

  1. The context in which the exception was raised is deleted completely before or after handling. This removes all procedures from the memory (and also their local data, which was called from the handler context and which caused the exception); handling is resumed depending on how the handler is exited.

  2. The context in which the exception was raised is retained and the program is resumed after the statement that raised the exception.

A prerequisite for the second case are resumable exceptions. These exceptions must be raised with the addition RESUMABLE of the statement RAISE EXCEPTION and declared using the addition RESUMABLE in the interface of the procedures from which they were propagated. The statement RESUME is used to resume the program.

Programming Guideline

Using Class-Based Exceptions




Continue
Exception Classes
System Response After a Class-Based Exception
RAISE EXCEPTION
TRY
Examples of Exceptions