ABAP Keyword Documentation → ABAP - Reference → Program Flow → 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
RETRY
statement allows you to retry aTRY
block that raised an exception right from the start. -
If the
BEFORE UNWIND
addition is declared for aCATCH
block, exiting usingRETRY
deletes the context of the exception and creates it again in theTRY
block. With respect to the context, therefore, RETRY responds like any exit of aCATCH
block (with the exception ofRESUME
. -
The cause of the exception must be removed either before
RETRY
in the CATCH block or afterRETRY
in theTRY
block. If aTRY
block 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.
PARAMETERS: number1 TYPE i,
number2 TYPE i.
DATA: result TYPE p DECIMALS 2,
msg TYPE c LENGTH 50.
TRY.
result = number1 / number2.
WRITE result TO msg LEFT-JUSTIFIED.
msg = `Result: ` && msg.
MESSAGE msg TYPE 'I'.
CATCH cx_sy_zerodivide.
number1 = 0.
RETRY.
ENDTRY.