Calling ABAP Programs Internally
From a user perspective there are two ways of starting programs: direct execution using the program name for executable programs, or selecting a transaction code for module pools. These two ways of calling programs can also be performed in ABAP programs that are already running. We have mentioned the relevant SUBMIT statement for executable programs. The corresponding statements for transactions are LEAVE TO TRANSACTION and CALL TRANSACTION. We can distinguish program calls from other ABAP programs by whether the calling program is being canceled completely or whether the called program is embedded in the calling program.
Canceling the calling program completely
You cancel the calling program completely by calling another program with SUBMIT prog.
LEAVE TO TRANSACTION transaction_code
When the SUBMIT statement is executed, the calling program is deleted from memory along with all its data. When the called program is ended the program execution returns to the point at which the calling program was started. This point can be a previous program in the call sequence.
When the LEAVE TO TRANSACTION statement is executed, all previous programs in the call sequence are deleted from memory along with their data, besides the calling program. When the called program is ended the program execution returns to the point at which the first program of the call string was started.
We will also encounter the LEAVE statement in other contexts. A LEAVE statement is used to quit a program context completely and the execution does not return to the statement directly after this point. Although LEAVE can be used without additions, we recommend using LEAVE always with an addition, such as TO TRANSACTION seen here. Otherwise it is often difficult to predict where the program execution will actually branch to at runtime, since the behavior depends on the call mode of the current program
Embedding the called program in the calling program
You can temporarily quit the calling program by calling another program with SUBMIT prog AND RETURN.
CALL TRANSACTION transaction_code.
In both cases, the calling program remains in memory with all its data. When the called program is terminated the program execution returns to the statement directly after the call location.
We will also see more of the CALL statement. CALL is the most important statement for temporarily quitting a program context in ABAP to execute another program unit. When the called unit is ended correctly the program returns behind the calling location.