Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

exit and stop statements

Former Member
0 Kudos

explain exit and stop statements in loops

3 REPLIES 3

varma_narayana
Active Contributor
0 Kudos

Hi..

When we use EXIT in a Loop: It will Terminate the LOOP processing and continues the execution immediately after the Loop.

When we use STOP in a Loop: It will Terminate the LOOP processing and Triggers the Event END-OF-SELECTION.

<b>Reward if Helpful</b>

Former Member
0 Kudos

Hi Mayuri,

Exit Statement will terminate the loop and continue with the rest of the program.

Stop Statement will branch out to the end of Selection event if End of Selection Event is not present it behaves same as EXIT.

Award Points if helpful..

Thanks,

Imran

Former Member
0 Kudos

Hi,

Hi,

STOP :This statement terminates a processing block in an excutable

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

Hope this helps you

reward if it helps..

Regards,

Omkar.