ABAP Keyword Documentation →  ABAP − Reference →  Program Flow Logic →  Exception Handling →  Class-Based Exceptions →  TRY → 

CLEANUP  Syntax Diagram

Short Reference

Syntax

CLEANUP [INTO oref].

Addition:

... INTO oref

Effect

Introduces a statement block of a TRY control structure where cleanups can be performed.

A CLEANUP block is executed when a class-based exception in the TRY block of the same TRY control structure is raised, but is handled in a CATCH block of an external TRY control structure. A CLEANUP block is executed immediately before the context of the exception is deleted:

The CLEANUP block must be executed completely and must be exited using ENDTRY so that the exception can be propagated to its handler. If an attempt is made to exit the context of a CLEANUP block prematurely, a runtime error occurs. A CLEANUP block cannot contain any statements where the system can detect (statically) that it cannot return to the CLEANUP block. Program calls using SUBMIT and CALL TRANSACTION should also be avoided here.

Notes

Addition

... INTO oref

Effect

If the addition INTO is specified, a reference to the exception object is saved to oref. The following can be specified for oref:

oref can be used to access the exception object.

Note

Within the CLEANUP block, do not raise the current exception again using RAISE EXCEPTION oref, since this would modify the attributes of the exception object.