EXIT (ABAP Keyword)

EXIT (ABAP Keyword) introduction & syntax details

EXIT


EXIT in loops and modularization units

 

Basic form
EXIT.

Effect
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

Example

TABLES T100.
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.
EXIT.
ENDIF.
ENDIF.
ENDSELECT.

Note
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

Basic form
EXIT FROM STEP-LOOP.

Effect
Leaves a step loop ( screen ). The current line and all subsequent lines are either not displayed ( PBO ) or not processed ( PAI ).

EXIT FROM SQL

Basic form
EXIT FROM SQL.

Effect
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 .