CLEANUP [INTO oref].
Introduction to a statement block of a
TRY control structure in which a cleanup can be performed.
CLEANUP block is executed exactly when a class-based exception in the
TRY block of the same
TRY control structure occurs, but is handled
CATCH block of an external
TRY control structure.
CLEANUP block is executed immediately before the context of the exception is deleted:
BEFORE UNWINDis specified for the handling
CATCHblock, the context is deleted when you leave the
CATCHblock and the
CLEANUPblock is executed accordingly after handling.
BEFORE UNWINDis not specified, the context is deleted before the
CATCHblock is executed and the
CLEANUPblock is executed accordingly.
If processing with
RESUMEis restarted after a restartable exception, the context is not deleted and accordingly no
CLEANUPblock is executed.
CLEANUP block must be executed completely and must be left with
ENDTRY so that the exception can be propagated to your handler. If you try to leave the context of a
CLEANUP block prematurely, a runtime error occurs. No
statements can be listed for which you can see statically that you cannot return to the
You can clean up the context of the
TRY block in a
block. For example, you can bring objects to a consistent state or release external resources which an external handler no longer had access to.
CLEANUPblock must always be executed completely, all the exceptions raised there must also be handled there.
... INTO oref
INTO is specified, a reference to the exception object in
oref is stored, whereby
oref must be an object reference variable of type CX_ROOT. You can access the exception object with
CLEANUP block, the current exception should not be triggered again with
RAISE EXCEPTION oref, as this would change the attributes of the exception object.