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

return statement

Former Member
0 Likes
6,242

what is return statement? why is it use for? what is the difference between return & exit ststements?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,580

hi,

The return option enables you to return control to a calling program. You choose this option when you are in a subroutine, function module, or other called program, and you want to return to the calling program.

exit is A standard R/3 function used to leave the current task or application area.

If data may be lost, the SAP System prompts you to save your work.

6 REPLIES 6
Read only

Former Member
0 Likes
3,581

hi,

The return option enables you to return control to a calling program. You choose this option when you are in a subroutine, function module, or other called program, and you want to return to the calling program.

exit is A standard R/3 function used to leave the current task or application area.

If data may be lost, the SAP System prompts you to save your work.

Read only

Former Member
0 Likes
3,580

hi,

EXIT statement exits from the report whereas RETURN statement returns u back to the report based on the condition u have given.

Read only

Former Member
0 Likes
3,580

Hi, Raman,

Check this below statemtn:

This will give you an idea than Screen calls List and once List is processed control is returned to the screen:

LEAVE TO LIST-PROCESSING [AND RETURN TO SCREEN <nnnn>].

SCREEN-> LIST and again SCREEN.

EXIT:stop/ Exit - Terminates the loop immediately. Processing continues at the statement immediately foollowing endloop.

DO 4 TIMES.

IF SY-INDEX = 3.

EXIT.

ENDIF.

WRITE SY-INDEX.

ENDDO.

The output is:

1 2

Reward if useful!

Read only

0 Likes
3,580

what is list-processing

Read only

Former Member
0 Likes
3,580

hi,

return statement is used for transfering control from subroutine to callina area. return statement is used for transfering output from subroutine to calling area or calling function.

exit statement is used to quit the execution of current program or in current loop.

for ex:

do 5 times.

if a = b.

exit.

write:/10 a.

endif.

enddo.

in the above ex when a = b then control comes out of do loop and continues with next statement after enddo.

if helpful reward some points.

with regards,

Suresh.A

Read only

Former Member
0 Likes
3,580

hi,

<b>CONTINUE:</b>

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.

<b>EXIT:</b>

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.

For list-processing follow this link.

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9d2f35c111d1829f0000e829fbfe/content.htm

regards,

Ashok reddy

Message was edited by:

Ashok Reddy