EXIT (ABAP Keyword) introduction & syntax details
EXIT in loops and modularization units
In loop structures:
Leaves the loop processing (DO , WHILE , LOOP , SELECT )
In subroutines and other modularization units (but outside loop structures):
Leaves the subroutine or modularization unit (FORM , MODULE , FUNCTION , TOP-OF-PAGE , END-OF-PAGE )
Outside loop structures and modularization units (report processing):
Cancels the report processing and displays the list
DATA SAP_COUNT TYPE I.
SELECT * FROM T100 WHERE SPRSL = SY-LANGU AND
ARBGB = ‘DS’.
WRITE / T100-TEXT.
IF T100-TEXT CS ‘SAP’.
ADD 1 TO SAP_COUNT.
IF SAP_COUNT = 3.
If there are several nested loops, the effect of EXIT is only to leave the current loop. Processing continues after the next END… statement in the next loop up.
EXIT FROM STEP-LOOP
EXIT FROM STEP-LOOP.
Leaves a step loop ( screen ). The current line and all subsequent lines are either not displayed ( PBO ) or not processed ( PAI ).
EXIT FROM SQL
EXIT FROM SQL.
Leaves loop processing of the selected lines introduced by EXEC SQL PERFORMING form . Leaves the function form and cancels the processing of the block of code introduced by EXEC SQL and concluded by ENDEXEC .