Get Example source ABAP code based on a different SAP table
Class-Based Exceptions Class-based exceptions are implemented as instances of exception classes>. Exception classes are either predefined globally in the system or can be defined by the user both globally and locally. Class-based exceptions are raised either by the ABAP runtime framework> or by a program.
Exception situations detected by the system and whose causes can be handled properly in the program, raise predefined class-based exceptions>.
The exceptions of all exception classes visible in a program can be raised by the program as follows:.
Using the statement RAISE EXCEPTION >>.
Using the addition THROW> > in conditional expressions>.
Class-based exceptions can be declared in the interface of procedures>. This is done using the addition RAISING> of the statements METHODS >> and FORM>>. BEGIN_SECTION VERSION 5 OUT In the form-based Class Builder> and Function Builder>, this is done by selecting exception classes when defining exceptions in the interface. END_SECTION VERSION 5 OUT The declared exceptions can occur at the call position of a procedure if the exception is not handled in the procedure. 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 full 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 superclasses. 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: The context in which the exception was raised is deleted completely before or after handling. This removes all procedures from the memory, including their local data, which was called from the handler context and caused the exception, and handling is resumed depending on how the handler is exited. 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 must be raised using 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.
ABAP_PGL Using Class-Based Exceptions > ABAP_PGL_END