Application Development and Automation 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: 
Read only

diff between exit and stop

Former Member
0 Likes
1,131

friends can any one tell me which is more useful to exit from the loop ..? that is i want to uplaod the data and process to internal tables,,suppose the file doesnt exists and want to jump out of program..?

to end of selection stating that file dosent exists..?

which one is more usefull? exit or stop..?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,052

Hi,

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.

Example

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.

STOP :

This statement terminates a processing block in an excutable program of type 1.

The statement is only intended for use in the INITIALIZATION, AT SELECTION-SCREEN, START-OF-SELECTION, and GET events. During the execution of type 1 programs, it terminates the processing of the associated event blocks and triggers the sending of the selection screen during the event INITIALIZATION, and - in all other cases - triggers the event END-OF-SELECTION of the runtime environment. In all other processing blocks or if END-OF-SELECTION is not desired, you must use RETURN or EXIT.

Thanks.

8 REPLIES 8
Read only

Former Member
0 Likes
1,053

Hi,

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.

Example

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.

STOP :

This statement terminates a processing block in an excutable program of type 1.

The statement is only intended for use in the INITIALIZATION, AT SELECTION-SCREEN, START-OF-SELECTION, and GET events. During the execution of type 1 programs, it terminates the processing of the associated event blocks and triggers the sending of the selection screen during the event INITIALIZATION, and - in all other cases - triggers the event END-OF-SELECTION of the runtime environment. In all other processing blocks or if END-OF-SELECTION is not desired, you must use RETURN or EXIT.

Thanks.

Read only

Former Member
0 Likes
1,052

Hi,

EXIT is generally used to exit from current processing within loops like LOOP ENDLOOP block or DO ENDDO block etc.

STOP is used to exit from other than loops. For Example You have written select command and you could not get any record then STOP from there. It will go directly to END-OF-SELECTION event

Mukesh Kumar

Read only

Former Member
0 Likes
1,052

hi satish,

i think STOP has some performance issue associated with it,

we cant use stop in module pool programs,

however ,in report programs it will take the control to end-of-selection immediately,

exit is more useful ..

Regards,

Talwinder

Read only

Former Member
0 Likes
1,052

Hi,

Exit : it exits from the loops but the thing is it will come print the write statements after the loop also ....

Stop: it will suspend from the loop but will not print the write statements ..

thats the main difference between exit and stop u can try this with a simple example.

Regards,

Sana.

reward points if found helpful....

Read only

Former Member
0 Likes
1,052

Hi,

Exit:

1) Within a loop structure:

Terminates looop processing ( DO,WHILE, LOOP, SELECT).

2) Within subroutines and other modularization units (but not in a loopstructure):

Leaves the subroutine or modularization unit (FORM, MODULE , FUNCTION,TOP-OF-PAGE,END-OF-PAGE).

3) Outside loop structures and modularization units (report processing):

Terminates report processing and triggers list display.

Example:

**********************************************************

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.

**********************************************************

STOP: This statement terminates a processing block in anexcutable program.

Note

The statement is only intended for use in theINITIALIZATION, AT SELECTION-SCREEN,START-OF-SELECTION, and GET events. It terminates thecurrent processing block in an executable program and triggers theEND-OF-SELECTION event. In all other processing blocks, or whenyou do not want to trigger the END-OF-SELECTION event, you mustuse EXIT.

Whenever you want to stop the program processing after some count you can use stop so that it goes to end-of-selection event .ther we can write some write stmts.

**********************************************************

Regds

Sivaparvathi

Please reward points if helpful...

Read only

Former Member
0 Likes
1,052

Hi,

To Exit from any loop statement then we can use ‘EXIT’ command.

If u use the EXIT outside the loop it will exit from that program.

Exit also used to exit from modules.

If EXIT is there then no execution of END-OF-SELECTION takes place.

But If STOP is there then execution of END-OF-SELECTION takes place.

AND STOP only use with REPORTS.

In u r case to exit from program use ‘EXIT’ is better I think.

Regards,

Mekala Vijay

Read only

Former Member
0 Likes
1,052

Hi,

STOP

If you use the STOP statement within an event block, the system stops processing the block immediately. The ABAP runtime environment triggers the next event.

Before and during selection screen processing, the next event in the prescribed sequence is always called. From the AT SELECTION-SCREEN event onwards, the system always jumps from a STOP statement directly to the END-OF-SELECTION statement. Once the corresponding event block has been processed, the system displays the list.

EXIT

If you use the STOP statement within an event block but not in a loop, the system stops processing the block immediately.

Before and during selection screen processing, the next event in the prescribed sequence is always called. From the START-OF-SELECTION event onwards, the system starts the list

processor directly when the EXIT statement occurs, and displays the list.

If the EXIT statement occurs in a loop using DO, WHILE, or LOOP, it is the loop that terminates, not the processing block.

Regards,

Bhaskar

Read only

Former Member
0 Likes
1,052

If you use the STOP statement within an event block, the system stops processing the block immediately. The ABAP runtime environment triggers the next event according to the following diagram:

A subroutine normally ends at the ENDFORM statement. However, you can terminate them earlier by using the EXIT or CHECK statement. When you terminate a subroutine with EXIT or CHECK, the current values of the output parameters (CHANGING parameters passed by value) are passed back to the corresponding actual parameter.

Use EXIT to terminate a subroutine unconditionally. The calling program regains control at the statement following the PERFORM statement.

PROGRAM FORM_TEST.

PERFORM TERMINATE.

WRITE 'The End'.

FORM TERMINATE.

WRITE '1'.

WRITE '2'.

WRITE '3'.

EXIT.

WRITE '4'.

ENDFORM.

The produces the following output:

1 2 3 The End