EXIT.
Exits the current loop processing in loop structures such as:
DO ... ENDDO
WHILE ...
ENDWHILE
LOOP ... ENDLOOP
SELECT ... ENDSELECT
Outside loop structures, the system exits the current processing block (event block, dialog module,
procedure). During report processing, that is, during the event blocks START-OF-SELECTION,
GET, END-OF-SELECTION,
the system goes to the basic list display.
SAP recommends that you use EXIT only in loops. To
exit processing blocks, use the statement RETURN.
DATA: SAP_COUNT TYPE I,
WA_T100 TYPE T100.
SELECT *
FROM T100 INTO WA_T100 WHERE SPRSL = SY-LANGU AND
ARBGB
= 'DS'.
WRITE / WA_T100-TEXT.
IF WA_T100-TEXT CS 'SAP'.
ADD
1 TO SAP_COUNT.
IF SAP_COUNT = 3.
EXIT.
ENDIF.
ENDIF.
ENDSELECT.
If several loops are nested, EXIT only exits the current
loop. The processing continues after the corresponding END... statement in the loop at the next higher level.
CONTINUE, CHECK,
REJECT, STOP, RETURN
Loops
Exiting Event Blocks