Sap Technology‎ > ‎ABAP DEVELOPMENT‎ > ‎

Difference between exit and stop in ABAP

Stop vs Exit

STOP
:This statement terminates a processing block in an executable  program.
The statement is only intended for use in the INITIALIZATION, AT SELECTION-SCREEN, START-OF-SELECTION, and GET events. It  terminates the current processing block in an executable  program and triggers the END-OF-SELECTION event. In all other
processing blocks, or when you do not want to trigger the  END-OF-SELECTION event, you must use EXIT.
EXIT.
- Within a loop structure:
Terminates loop processing (DO, WHILE, LOOP, SELECT).
- Within subroutines and other modularization units (but not  in a loop structure):
Leaves the subroutine or modularization unit (FORM, MODULE,  FUNCTION, TOP-OF-PAGE, END-OF-PAGE).
- Outside loop structures and modularization units (report  processing):
Terminates report processing and triggers list display.

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.

Comments