ABAP Keyword Documentation → ABAP − Reference → Program Flow Logic → Exception Handling → Class-Based Exceptions → TRY
RETRY
Other versions: 7.31 | 7.40 | 7.54
Syntax
RETRY.
Effect
This statement exits the CATCH handling of a
class-based exception
and continues processing with the TRY statement of the current TRY control structure.
The RETRY statement can only be executed in a CATCH block of a TRY control structure.
Notes
-
The
RETRYstatement enables aTRYblock that raised an exception to be executed again right from the start. -
If the
BEFORE UNWINDaddition is declared for aCATCHblock, exiting usingRETRYdeletes the context of the exception and creates it again in theTRYblock. With respect to the context, therefore, RETRY responds like any exit of aCATCHblock (with the exception ofRESUME. -
The cause of the exception must be removed either before
RETRYin the CATCH block or afterRETRYin theTRYblock. If aTRYblock is repeated and the cause of the exception is not removed, an endless loop results.
Example
The following exception handling extends the ABAP-specific handling of a division by zero to dividends not equal to zero, by setting these to the value zero before a second pass.
DATA: number1 TYPE i,
number2 TYPE i.
cl_demo_input=>add_field( CHANGING field = number1 ).
cl_demo_input=>request( CHANGING field = number2 ).
DATA result TYPE p DECIMALS 2.
TRY.
result = number1 / number2.
cl_demo_output=>display( |Result: { result ALIGN = LEFT }| ).
CATCH cx_sy_zerodivide.
number1 = 0.
RETRY.
ENDTRY.