Application Development 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: 

Differnece between EXIT and LEAVE TO SCREEN or LEAVE PROGRAM?

Former Member
0 Kudos
5,897

HI Experts,

Differnece between EXIT and LEAVE TO SCREEN or LEAVE PROGRAM?

thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos
1,154

EXIT

Terminates a loop or processing block

LEAVE for Screens

Leaves a screen.

Syntax

LEAVE SCREEN.

Terminates the current screen and calls the next screen. The next screen can either be defined statically in the screen attributes or set dynamically using the SET SCREEN statement.

Syntax

LEAVE TO SCREEN <scr>.

Terminates the current screen and calls the dynamically-defined next screen <scr>.

LEAVE for Programs

Terminates an ABAP program.

Syntax

LEAVE [PROGRAM].

Terminates the current program and returns to the point from which it was called

if useful reward points.

5 REPLIES 5

Former Member
0 Kudos
1,154

Hi

EXIT -Exits leaves that Loop/procesing blocl

LEAVE to Screen: this used in Module pool programs to go to other screen

LEAVE program: this also used in Module pool programs to go to other screen

In PAI of screen

case OK_CODE.

when 'BACK'.

LEAVE TO SCREEN '0100'.

WHEN 'EXIT'.

LEAVE PROGRAM.

endcase.

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

Regards

Anji

Former Member
0 Kudos
1,154

Hi,

this is based on what u want to do after thes key words u have used,

EXIT and LEAVE TO SCREEN or LEAVE PROGRAM?

1. do your program need to carry out further coding after these statements.

2. do you program come back to the screen where it has started....

LEAVE TO SCREEN:

CALL mode continues after the CALL SCREEN statement. Otherwise, you branch to the transaction selection screen

LEAVE PROGRAM: always leaves the current program - there is never any processing after LEAVE PROGRAM)

Former Member
0 Kudos
1,155

EXIT

Terminates a loop or processing block

LEAVE for Screens

Leaves a screen.

Syntax

LEAVE SCREEN.

Terminates the current screen and calls the next screen. The next screen can either be defined statically in the screen attributes or set dynamically using the SET SCREEN statement.

Syntax

LEAVE TO SCREEN <scr>.

Terminates the current screen and calls the dynamically-defined next screen <scr>.

LEAVE for Programs

Terminates an ABAP program.

Syntax

LEAVE [PROGRAM].

Terminates the current program and returns to the point from which it was called

if useful reward points.

Former Member
0 Kudos
1,154

Hi,

LEAVE PROGRAM.

Effect

Leaves the current program and continues processing after CALL TRANSACTION, CALL DIALOG or SUBMIT prog AND RETURN .

If you use LEAVE TO TRANSACTION, SUBMIT prog or start the program via the transaction menu or a transaction code, you branch to the transaction selection screen.

Note

LEAVE PROGRAM always leaves the current program - there is never any processing after LEAVE PROGRAM!

leave to screen

a) IMMEDIATELY LEAVES THE CURRENT SCREEN

AND SWITCHES TO SCREEEN XYZ

(DOES NOT COMPLETE PAI PROCESSING)

EXIT

At EXIT command is available in module pool programming. This is used to terminate your currrent process or cancel function of SAP.

****do rewards if usefull

vijay

Former Member
0 Kudos
1,154

Syntax

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

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

LEAVE [TO] SCREEN

Syntax

LEAVE { SCREEN | {TO SCREEN dynnr} }.

Variants:

1. LEAVE SCREEN.

2. LEAVE TO SCREEN dynnr.

Effect

This statement ends the processing of the current screen. The current processing block of the ABAP program and the current processing block of the dynpro are left immediately.

Variant 1

LEAVE SCREEN.

Effect

The variant LEAVE SCREEN calls the current next screen. This is either statically specified in the properties of the current screen or has been set before using the statement SET SCREEN.

Variant 2

LEAVE TO SCREEN dynnr.

Effect

The variant LEAVE TO SCREEN calls the screen with the number dynnr as the next screen. A data object of the type n of the length 4 is expected for dynnr. It must contain either the screen number of a screen in the main program of the current program group or the value 0. Otherwise, an exception that cannot be handled is raised. This statement is a short form of the statements SET SCREEN dynnr and LEAVE SCREEN.

Note

This statement does not terminate the entire dynpro sequence; it branches to an additional screen in the same sequence. Only if the number 0 is used to branch to the next screen, LEAVE SCREEN terminates the screen sequence.

LEAVE PROGRAM

Syntax

LEAVE PROGRAM.

Effect

This statement immediately ends the current main program and deletes its internal session - including all loaded programs, instances, and their data .

The LEAVE PROGRAM statement can appear anywhere within any processing blocks. It ends the program regardless of the program/object or the program group of the internal session in which it is executed.

Regards,

Pavan P.