CATCH block. If the addition is not specified, the context is deleted
before the CATCH block is executed.
Latest notes: If the addition BEFORE UNWIND is specified, the
statement RESUME can be used in the CATCH
block for handling a resumable
exception , to resume processing after the statement that raised the
exception. This is the only case in which the context of the exception
is not deleted when the CATCH block is exited.
Resumable exceptions can also be handled in CATCH blocks
without the addition BEFORE UNWIND . In this case, the context of
the exception is deleted before the handling process and the statement
RESUME cannot be specified.
Any CLEANUP blocks are always executed
directly before their context is deleted. If BEFORE UNWIND is
used, after exception handling, and in all other cases before the
exception handling.
Use of the addition BEFORE UNWIND for CATCH is only
required when you use the statement RESUME .
However, it is allowed in principle during exception handling if the
context of the exception is to be evaluated before any cleanup
activities in CLEANUP blocks. This makes
sense, for example, when handling resource bottlenecks if releasing
resources in CLEANUP blocks would change the context and thus
make the calculation of the free resources in the exception handler
meaningless. Other than for logging purposes, we do not recommend
evaluating the part of the context that is only of interest locally for
implementing the incorrect procedure.
ABAP_ADDITION_2 ... INTO oref
What does it do? If the addition INTO is specified, a reference to
the exception object is saved to oref . The following can be
specified for oref :
An existing object reference variable oref , whose static type
must be more general or as general as the most general of the specified
exception classes.
An inline declaration with DATA(var) .
The static type of the declared object reference variable is the
exception class (if specified). If multiple exception classes are
specified and a common superclass of these classes is used, the
superclass is the static type of oref ; if not, it is CX_ROOT
.
The object reference variable can be used to access the attributes and
methods of the exception object.
Example ABAP Coding Catches exceptions with an inline declaration of an
object reference variable. The static type of this variable is cx
.
CLASS cx DEFINITION INHERITING FROM cx_dynamic_check.
PUBLIC SECTION.
ENDCLASS.
CLASS cy DEFINITION INHERITING FROM cx.
PUBLIC SECTION.
ENDCLASS.
TRY.
...
CATCH cy cx INTO DATA(oref).
ENDTRY.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved