The figure illustrates the situation before a program call is made.
The starting point for the first example is the execution of a SUBMIT ... AND RETURN or CALL TRANSACTION statement within a program (that is, the insertion of a program).
Inserted Program
When you insert a program, the system creates a new internal session that contains the new program context. The system places the new session in the stack. The program context of the calling program remains in the stack.
After the Inserted Program Ends
When the called program is completed, the system deletes the called program’s internal session (the top one in the stack). The system then begins processing the next-highest internal session in the stack.
Before Starting a New Executable Program
When a program is ended and a new one started, there is a difference between calling an executable program using the SUBMIT statement, and calling a transaction using the LEAVE TO TRANSACTION statement, with regard to memory areas.
The starting point for the next case is the execution of a SUBMIT statement within a program.
The New Executable Program Runs
When you start an executable program with the SUBMIT statement, the following actions occur:
Before Starting a New Transaction
The starting point for the third case is the execution of a LEAVE TO TRANSACTION statement within a program.
The New Transaction Runs
When you start a transaction using the LEAVE TO TRANSACTION statement, the system destroys all internal sessions in the stack. The system then creates a new internal session, which contains the program context of the called program.
The system initializes the complete stack of internal sessions, which also means it initializes ABAP memory after the call.
Memory Management for Calls of Function Modules and Methods
When an internal session is opened, the system always creates the main program group.
Any number of additional program groups can be created in the same internal session. Each program group has only one main program.
An additional program group is created in the following cases:
The system loads each function group and each global class only once into a given internal session.
Same Function Group in Different Internal Sessions
When two programs running in different internal sessions call up function modules from the same function group, the system loads the function group into each of the internal sessions separately. The system creates the global data of the function group separately in each internal session. Therefore, there is no possibility or risk of the two main programs exchanging data through the function group.
Same Class in Different Internal Sessions