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

Former Member
0 Likes
551

I wrote one exam in the sapdomain and it has got one question as follows.

if we have Exit in the loop of a sub Routine which is called from a programme what is the output.

The sapdomain gave the answer as exit from loop. But I read in the book as if we have exit in the program, the program comes out and displays the list which is contradicting from the above. Please clarify. please eloborate as much as possible.

Thank you

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
531

hi

good

the EXIT command works as per the use, as per the question you got in sapdomain the EXIT commnad had been used inside the LOOP so it come out from the loop, if the same EXIT command used inside the program than it would have been comout from the program.

the EXIT command works as per current flow of the program, if current flow is inside the loop statement than it comes out from that particular loop statement , and if the same EXIT command is inside the program than it ll come out from that program.

thanks

mrutyun^

3 REPLIES 3
Read only

suresh_datti
Active Contributor
0 Likes
531

What you read & got in the exam are both correct. Only the context differs.. that is the reason SAP recommends use of EXIT only inside a loop; To exit processing blocks, use the statement RETURN.

~Suresh

Read only

Former Member
0 Likes
531

The behaviour of exit is diff in diff situations

if you use it in coditional loops like do..enddo, while..endwhile and loop and loop ....it will comeout of the conditional loop.

and it behaves diff in events...

if you use exit in your prog it won't leave the prog but it depends where you used exit.

for example if you use exit after start-of-selection then program goes to the list(report output) without processing further.

if you use in initialization then it will directly to the selection screen without processing further.

Read only

Former Member
0 Likes
532

hi

good

the EXIT command works as per the use, as per the question you got in sapdomain the EXIT commnad had been used inside the LOOP so it come out from the loop, if the same EXIT command used inside the program than it would have been comout from the program.

the EXIT command works as per current flow of the program, if current flow is inside the loop statement than it comes out from that particular loop statement , and if the same EXIT command is inside the program than it ll come out from that program.

thanks

mrutyun^