SAP CLEANUP - Guide
Get Example source ABAP code based on a different SAP table
Cleanups After Exceptions
ABAP_BACKGROUND
Every
The addition
ABAP_RULE
Before forwarding an exception to higher-level call layers, perform the necessary cleanups in the
ABAP_DETAILS
Each exception changes the program flow and can thus pose a significant risk to the consistency of an application. If you decide not to handle an exception, but to
ABAP_EXAMPLE_BAD
The following source code shows the forwarding of an exception without first explicitly closing an open resource (in this case a database cursor). The closing of the database cursor is implicitly delegated to any exception handler.
OPEN CURSOR db_cursor
FOR SELECT ...
...
CATCH cx_sy_sql_error INTO exc.
RAISE EXCEPTION TYPE cx_persistency_error
EXPORTING previous = exc.
ENDTRY.>
ABAP_EXAMPLE_END
ABAP_EXAMPLE_GOOD
The following source code shows the same example as above, but the database cursor is closed in the
OPEN CURSOR db_cursor
FOR SELECT ...
...
CATCH cx_sy_sql_error INTO exc.
RAISE EXCEPTION TYPE cx_persistency_error
EXPORTING previous = exc.
CLEANUP.
CLOSE CURSOR db_cursor.
ENDTRY.>
ABAP_EXAMPLE_END