Question: Could you tell me the difference between exit and stop when used in different situations like inside loop,i the program etc?
Answer:
Hi,
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.
via https://forums.sdn.sap.com/thread.jspa?threadID=404985&tstart=61350
Responses to “Difference between exit and stop in ABAP”