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

stop.

Former Member
0 Likes
983

hi experts,

what is the deference bwstop and exit.while using these all functionlatyies means loop,subroutines,modules.

thanks in advance.

radhakrishna.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
951

Hi

STOP: Stops the program and goes to End of selection

EXIT : exits that processing block or Loop pass

<b>Reward points for useful Answers</b>

Regards

Anji

7 REPLIES 7
Read only

Former Member
0 Likes
951

ABAP contains termination statements that allow you to terminate a loop prematurely. There are two categories of termination statement - those that only apply to the loop, and those that apply to the entire processing block in which the loop occurs. The STOP and REJECT statements belong to the latter group, and are described in more detail under Leaving Event Blocks.

The termination statements that apply only to the loop in which they occur are CONTINUE, CHECK, and EXIT. You can only use the CONTINUE statement in a loop. CHECK and EXIT, on the other hand, are context-sensitive. Within a loop, they only apply to the execution of the loop itself. Outside of a loop, they terminate the entire processing block in which they occur (subroutine, dialog module, event block, and so on).

CONTINUE, CHECK, and EXIT can be used in all four loop types in ABAP (DO, WHILE, LOOP, and SELECT).

To terminate a single loop pass immediately and unconditionally, use the CONTINUE statement in the statement block of the loop.

After the statement, the system ignores any remaining statements in the current statement block, and starts the next loop pass.

DO 4 TIMES.

IF SY-INDEX = 2.

CONTINUE.

ENDIF.

WRITE SY-INDEX.

ENDDO.

The output is:

1 3 4

The second loop pass is terminated without the WRITE statement being processed.

Terminating a Loop Pass Conditionally

To terminate a single loop pass conditionally, use the CHECK <condition> statement in the statement block of the loop.

If the condition is not true, any remaining statements in the current statement block after the CHECK statement are ignored, and the next loop pass starts. <condition> can be any logical expression.

DO 4 TIMES.

CHECK SY-INDEX BETWEEN 2 and 3.

WRITE SY-INDEX.

ENDDO.

The output is:

2 3

The first and fourth loop passes are terminated without the WRITE statement being processed, because SY-INDEX is not between 2 and 3.

Exiting a Loop

To terminate an entire loop immediately and unconditionally, use the EXIT statement in the statement block of the loop.

After this statement, the loop is terminated, and processing resumes after the closing statement of the loop structure (ENDDO, ENDWHILE, ENDLOOP, ENDSELECT). In nested loops, only the current loop is terminated.

DO 4 TIMES.

IF SY-INDEX = 3.

EXIT.

ENDIF.

WRITE SY-INDEX.

ENDDO.

The output is:

1 2

In the third loop pass, the loop is terminated before the WRITE statement is processed.

u can visit:

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3564358411d1829f0000e829fbfe/content.htm

for further info

Regards,

Pavan

Read only

Former Member
0 Likes
952

Hi

STOP: Stops the program and goes to End of selection

EXIT : exits that processing block or Loop pass

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
951

stop triggers end of selection

where as exit in loop,subroutines,modules comes out of that respective module and excution continues from next executable statement

and exit in the code part will come out of the code

Read only

Former Member
0 Likes
951

Hi,

if we use the exit statement

in any kind of module or loop it will come out of that and continues the next part of the code.

if we stop

in the start of selection event and what ever may be the looop or module

it will come toend of selection

and if you give information message followed with stop

then it willl go to selection screen of the program

if it is an error message with stop statement

it will leave the selection screen and remains a blank page for you...

reward points if helpful.

thanks & regards,

venkatesh

Read only

Former Member
0 Likes
951

hi

<b>STOP </b>

Effect

The statement STOP is only to be used in executable programs and in the following event blocks:

AT SELECTION-SCREEN (without additions)

START-OF-SELECTION

GET

You leave these event blocks via STOP, and the runtime environment triggers the event END-OF-SELECTION.

Note

The statement STOP is forbidden in methods and, since Release 6.10, leads to an uncatchable exception during the processing of screens called with CALL SCREEN and in programs not called with SUBMIT.

<b>Example </b>

Ending the event blocks GET sbook after max postings have been issued, and branching to END-OF-SELECTION.

NODES: sflight, sbook.

DATA: bookings TYPE i,

max TYPE i VALUE 100.

GET sflight.

WRITE: / sflight-carrid, sflight-connid, sflight-fldate.

GET sbook.

bookings = bookings + 1.

WRITE: / sbook-bookid, sbook-customid.

IF bookings = max.

STOP.

ENDIF.

END-OF-SELECTION.

ULINE.

WRITE: / 'First', bookings, 'bookings'.

<b>EXIT - loop </b>

Syntax

EXIT.

Effect

If the EXIT statement is listed within a loop, it leaves the loop by ending the current loop process. Program execution is continued after the closing statement in the loop.

Note

Outside of a loop, the EXIT statement leaves the current processing block (see EXIT - Processing block). We recommend that you use EXIT within loops only.

Example

Leaving a loop with EXIT if the loop index sy-index is greater than a number limit.

DATA limit TYPE i VALUE 10.

DO.

IF sy-index > limit.

EXIT.

ENDIF.

WRITE / sy-index.

ENDDO.

regards

ravish

<b>plz dont forget to reward points if useful</b>

Read only

Former Member
0 Likes
951

Hi,

STOP:

Effect

The statement STOP is only to be used in executable programs and in the following event blocks:

AT SELECTION-SCREEN (without additions)

START-OF-SELECTION

GET

You leave these event blocks via STOP, and the runtime environment triggers the event END-OF-SELECTION.

EXIT.

Effect

If the EXIT statement is executed outside of a loop, it will immediately terminate the current processing block.

After the prodessing block has been executed, the runtime environment behaves in such a way that it follows with the exception Reporting Event Blocks START-OF-SELECTION and GET the schema from Leave Processing Blocks.

After the Reporting Processing Blocks START-OF-SELECTION and GET have been exited using EXIT, the runtime environment does not trigger any further reporting events. Instead, it directly calls the list processor for displaying the basic list.

Note

SAP recommend using EXIT only within loops (see EXIT (loops) ). Instead, use RETURN to leave processing blocks.

Jogdand M B

Read only

Former Member
0 Likes
951

Hi,

<u><b>STOP</b></u>

Exits a reporting event.

Syntax

STOP.

Can only occur in event blocks for reporting events. Leaves the block and jumps to END-OFSELECTION.

<u><b>EXIT</b></u>

Terminates a loop or processing block.

Syntax

EXIT.

Within a loop: The entire loop is terminated, and processing continues with the first statement following the loop.

Outside a loop: Terminates the current processing block.

In a reporting event: Jumps directly to the output list.

Regards,

Bhaskar