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 to

Former Member
0 Likes
1,083

When I use EXIT command in subroutine its comming out of subroutine, but according to my requit=rement it has to come out of the program,

how can this be done.

When I use EXIT command in subroutine its comming out of subroutine, but according to my requit=rement it has to come out of the program,

how can this be done.

6 REPLIES 6
Read only

Former Member
0 Likes
1,068

Hi,

Use LEAVE PROGRAME

Don't forget to reward if useful...

Read only

Former Member
0 Likes
1,068

LEAVE PROGRAM

Read only

Former Member
0 Likes
1,068

Hi,

You can use any of the following statements :



STOP

LEAVE PROGRAM

LEAVE TO selection-screen.

LEAVE TO SCREEN 0.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,068

hi

exit----if it is in the loop comes out of the loop.

-


if it is in the subroutine comes out of the routine.

-


if it is in the program comes out of the program.

use stop.

Read only

Swetabh
Explorer
0 Likes
1,068

Hi

Properties of 'Exit'

1- If used inside loop, it will end loop processing and come out of loop.

2- If used outside the loop, it leaves current processing block.

So to come out of program, set a flag inside the subroutine and then exit from that subroutine. Just after that subroutine call. Check that flag using 'if' and then again call 'exit'. This time it will leave the processing completely.

Check code below:

REPORT ytest_swet2.

data : gv_flag type c.

START-OF-SELECTION.

PERFORM rms.

break-point.

IF gv_flag = 'x'.

*The control will leave the program

EXIT.

ENDIF.

PERFORM sms.

&----


*& Form rms

&----


FORM rms .

*

  • Above write other code

  • When need to leave program update the flag and come out

gv_flag = 'x'.

EXIT.

ENDFORM. " rms

&----


*& Form sms

&----


FORM sms .

WRITE : 'sms'.

ENDFORM. " sms

First of all subroutine rms is called. The control comes out of the subroutine and the flag gv_flag is set to x. Further again we are checking the flag and exiting the program.

Also we can call 'Leave program' to directly come out of program in this case.

Read only

Former Member
0 Likes
1,068

Hi

good

I would suggest you to debug the report properly and place the exit statement at the right place.

thanks

mrutyun^