Show TOC

Calling ProgramsLocate this document in the navigation structure

If you need to program an extensive application, one single program can become very complex. To make the program easier to read, it is often a good idea to divide the required functions among several programs.

As well as using external modularization , in which you store procedures in special non-executable ABAP programs like function groups, you can also call independent programs from within an ABAP program.

The following ABAP statements allow you to start an executable program or transaction. You can either exit the calling program, or have the system return to it when the called program finishes running.

  Executable Program Transaction

Call without return

SUBMIT

LEAVE TO TRANSACTION

Call with return

SUBMIT AND RETURN

CALL TRANSACTION

You can use these statements in any ABAP program. For example, while processing a user action in the output list of an executable program, you might call a transaction whose initial screen is filled with data from the selected list line.

The event LOAD-OF-PROGRAM is triggered each time a program is called. If a corresponding event block is defined in the framework program, it is executed once before the first other processing block is executed.

An interesting remark at this point is that each execution of an executable program actually has a SUBMIT statement as its source. When you enter the program name in a transaction like SE38 or SA38 and choose Execute, a SUBMIT statement occurs in the transaction. Technically speaking, therefore, executable programs have the attribute of being able to be called using SUBMIT, although their principal characteristic from a user's point of view is that they are started in the foreground.

Memory Organization in Program Calls

The first ABAP program in a session on the application server opens its own internal session (roll area) within the main session. All externally-called procedures run in the same internal session as the calling program, that is, the main program and working data of the procedure are loaded into the same memory area in the internal session.

When you call an executable program or a transaction, the system opens a new internal session for each program. Here, there are two possible cases: If the second program does not return control to the calling program when it has finished running, the called program replaces the calling program in the internal session. The contents of the memory of the calling program are deleted. If the second program does return control to the calling program when it has finished running, the session of the called program is not deleted. Instead, it becomes inactive, and its memory contents are placed on a stack. The system can open up to 9 further internal sessions in external program calls.

As well as executable programs and transactions, dialog modules also open a new internal session. Dialog modules were previously used for modularizing screen sequences.

Program Calls and SAP LUWs

An SAP LUW is a logical unit consisting of dialog steps, whose changes are written to the database in a single database LUW. There are various bundling techniques that you can use to ensure that all of the database updates belonging to an SAP LUW are made in the same single database LUW.

Externally-called procedures do not open a new SAP LUW.

However, when you start a new executable program or transaction, a new SAP LUW starts. Database updates belonging to these programs are collected in their own database LUW. If the new program does not return control to the calling program, the SAP LUW of the old program concludes when the new program is called. If, on the other hand, the new program does return control to the calling program, the new SAP LUW runs parallel to the SAP LUW of the calling program.

No new SAP LUW is opened when you call a dialog module. Bundling techniques in a dialog module add the database updates to the database LUW of the calling program. You may sometimes need to call a transaction that runs in the same SAP LUW as the calling program. One technique for doing this is to use the existing transaction as a dialog module. To do this, you need to create a new dialog module with the same main program and initial screen as the transaction. Transactions that are used both as transactions and as dialog modules must be programmed to obey certain rules. For further information, refer to Calling Screen Sequences .

The fact that an external program shares (or does not share) the SAP LUW with its caller has special consequences if the program calls update-task functions or uses COMMIT WORK. For further information, refer to Special LUW Considerations .

For more information, see:

Overview of Program Calls

Calling Executable Programs

Direct Execution

Transactions

Passing Data Between Programs