RETRY statement can only be executed in a
CATCH block of a
TRY control structure.
RETRYstatement allows you to retry a
TRYblock that raised an exception right from the start.
BEFORE UNWINDaddition is declared for a
CATCHblock, exiting using
RETRYdeletes the context of the exception and creates it again in the
TRYblock. With respect to the context, therefore, RETRY responds like any exit of a
CATCHblock (with the exception of
The cause of the exception must be removed either before
RETRYin the CATCH block or after
TRYblock. If a
TRYblock is repeated and the cause of the exception is not removed, an endless loop results.
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.