ABAP Keyword Documentation → ABAP - Reference → Program Flow → Exception Handling → Exceptions Before Class-Based Exceptions
Non-Class-Based Exceptions
Other versions: 7.31 | 7.40 | 7.54
Definition
Non-class-based exceptions can be defined in the interfaces of function modules and methods. These exceptions are defined as follows:
- For methods of local classes, by assigning a name for the exception after the
EXCEPTIONS
addition of the statement [CLASS-]METHODS
.
- For methods of global classes or function modules, by assigning a name for the exception in the Class Builder or the Function Builder, in which case the radio button for exception classes is not selected.
The statement RAISE EXCEPTION
,
which is designed to raise class-based exceptions, is not allowed in a method or a function module in whose interface non-class-based exceptions are defined.
Note
Before class-based exceptions were introduced, all exceptions defined in the interface of methods of global classes or function modules were non-class-based.
Raising
Non-class-based exceptions are raised by the following statements:
Handling
The handling of non-class-based exceptions is made possible by the addition EXCEPTIONS
in
method calls and in
function module calls. Numeric values are assigned
to the exceptions, which are used to fill the system field sy-subrc
when
the exception is raised. The actual error handling takes place after the call, when the system evaluates sy-subrc
.
Programming Guideline
Notes
- The exceptions that can be defined in the interfaces of methods and function modules are not real exceptions, since they do not modify the control flow; instead they just end the processing of the
procedure prematurely and set the return code
sy-subrc
.
- RFC currently allows only classical exception handling. Class-based exception handling is only possible in a different release track.