Get Example source ABAP code based on a different SAP table
ID CLEANUP • CLEANUP ABAP Statement
CLEANUP> Short Reference >
ABAP_SYNTAX CLEANUP $[INTO oref$].>
ABAP Addition ... INTO oref>
What does it do? Introduces a statement block of a TRY>> control structure where cleanups can be performed. A CLEANUP> block is executed exactly 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:
If the addition BEFORE UNWIND> is specified for the handling CATCH>> block, the context is deleted when the CATCH> block is exited, and the CLEANUP> block is executed accordingly after handling.
If the addition BEFORE UNWIND> is not specified, the context is deleted before the CATCH> block is executed and the CLEANUP> block is executed accordingly before it is processed.
If RESUME>> is used to resume processing after a resumable exception>, the context is not deleted and therefore no CLEANUP> block is executed. 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. No statements> can be specified in a CLEANUP> block where it is statically known that returning to the CLEANUP> block is not possible. Program calls using SUBMIT>> and CALL TRANSACTION>> should also be avoided here.
Latest notes:
The context of the TRY> block can be cleaned up in a CLEANUP > block. For example, objects can be updated to a consistent state or external resources released to which an external handler would no longer have access.
Since a CLEANUP> block must always be executed completely, all the exceptions raised there must also be handled there. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 In an inner TRY> block, either the exception cx_demo0> or cx_demo1> can be raised. If cx_demo1> is raised, the CLEANUP> block of the inner TRY> block is executed before handling in the outer TRY> block. ABEXA 00107 ABAP_EXAMPLE_END
ABAP_EXAMPLES_ABEXA
Exceptions, TRY>>
Exceptions, CATCH>> ABAP_EXAMPLE_END • INTO CLEANUP
ABAP Addition
What does it do? If the addition INTO> is specified, a reference to the exception object is stored in oref>. The following can be specified for oref>:
An existing object reference variable of the type CX_ROOT>
An inline declaration DATA(var)>> or FINAL(var)>>, where an object reference variable of the type CX_ROOT> is declared. oref> can be used to access the exception object.
Latest notes:
Within the CLEANUP> block, the current exception should not be raised again using RAISE EXCEPTION oref>, since this would modify the attributes of the exception object.
Within a CLEANUP> block, the attribute IS_RESUMABLE> of the exception object is undefined. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The CLEANUP> block of the inner TRY> block is executed before handling of the exception cx_demo1> in the outer TRY> block. The reference variable exc> points to the exception object of the class cx_demo1>. ABEXA 00108 ABAP_EXAMPLE_END