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

Exit Statement

Former Member
0 Likes
793

Hi Friends,

Any one Explain Exit Statement with Example

Regards,

Maya

6 REPLIES 6
Read only

Former Member
0 Likes
765

hi,

Exit statement means coming out of a loop when ever certain conditon sastisfies


 do.
   count = count + 1.  

 if count = '5'.
   EXIT.
 endif.
 enddo.

Refer this to understand better

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/exit_.htm

Regards,

Santosh

Read only

Former Member
0 Likes
765

Hi Maya,

EXIT statement is the control break statement. If you put this statement in the loop then the control will come our of the loop and excute the next statement after the Endloop.

If this statement in Subroutine then it will come out of the the routine and exxcute the next statement of the perform statement.

If this statement in if condition then it will comeout of that Event .

I think this will understand you clearly

Warm Regards,

Vijay

Read only

Former Member
0 Likes
765

Hi,

Exit can be used to get out of loops like Do, Loop, While and

Select Endselect, for a particular condition.

Thanks

Sandeep

Reward if helpful

Read only

Former Member
Read only

Former Member
0 Likes
765

Hi Maya,

The <b>exit</b> statement prevents further processing from occurring.

Syntax for the exit Statement

exit.

Sample Program

Using EXIT to Stop Program Processing Dead in Its Tracks

1 report ztx1006.

2 write: / 'Hi'.

3 exit.

4 write: / 'There'.

The code produces this output:

Hi

Exit prevents further processing, so the exit on line 3 prevents line 4 from being executed.

exit can be used in many situations. It can have varying effects depending on where it appears in the code. However, it always prevents further processing. Within loop structures, it leaves loop processing introduced by statements such as loop, select, do, and while. Within subroutines, it leaves subroutines introduced by FORM. Its effects in other situations will be fully explored as they arise.

Hope this resolves your query.

Reward all the helpful answers.

Regards

Read only

Former Member
0 Likes
765

Hi MAYA,

If u use the exit statement in loop.

To terminate the loop entirely without any condition.

Syntax:

Do 4 times.

If sy-index = 3.

Exit.

Endif.

Write sy-index.

Enddo.

The syatem terminate s the entire loop processing.

Rewords some points,

Rgds,

P.Nag