ABAP Geek 4 The Mystery of SUBMIT Unveiled
In a recent blogpost, I have talked a bit of ABAP program execution via transaction codes. Now, let’s talk about the kind of program execution, that is reserved for exactly one program type, namely executables, let’s talk about SUBMIT.
Executable programs are only directly executable from the end user’s perspective. Whenever an executable program is started using System → Services → Reporting the SUBMIT statement is executed. The correct name for a “Executable Program” would rather be “ Submitable Program”, but who would understand that?
The statement SUBMIT rep … starts an executable program named rep. It has quite a lot of options:
- With one set of additions, you can determine the selection screen of the called program and supply it with values.
- With another set of additions, you can influence the output medium (screen, spool, memory) and the page size for the for the called program.
- With a last set of additions, you can schedule the called program for background processing.
I don’t want to go into details about this. All additions are neatly documented (at least for Release 6.40).
But I want to go into details about what happens after SUBMIT. Of course, that is neatly documented too (OK, as of Release 6.40 …) but maybe you havent.
What really happens after SUBMIT
The SUBMIT statement loads the called program in a separate internal session (see an upcoming blog about that) and starts a series of processes in the ABAP runtime environment that trigger events and actions in the called program in the following order:
- LOAD-OF-PROGRAM (a kind of program constructor, always triggered when a program is loaded into memory)
- The start values defined using the DEFAULT addition in the statements PARAMETER and SELECT-OPTIONS are passed to the relevant data objects. The start values of all other data objects are set before LOAD-OF-PROGRAM.
- Reporting event INITIALIZATION
- The selection screen specified in the respective addition is called if it contains at least one input field or button. Complete selection screen processing is performed. Before the first event of the selection screen processing, AT SELECTION-SCREEN OUTPUT, the values specified in the respective additions are passed.
- Reporting event START-OF-SELECTION
- Different GET events (normally processed in loops), if the called program is linked with a logical database.
- Reporting END-OF-SELECTION
- The basic list is called. If the basic list is empty, the program is exited.If the basic list is a spool list, it is sent to the SAP spool system and the program is exited. If EXPORTING LIST TO MEMORY is specified in the respective additions, the basic list is stored in the ABAP Memory and the program is exited. Otherwise, the basic list is a screen list and is displayed on the screen. User actions on a displayed screen list trigger list events. The program is exited when the user exits the list display.
- If no selection screen is displayed in step 4, because its processing is performed darkly or there is no selection screen, the program flow is complete.
- If a selection screen is displayed in step 4, the runtime environment calls the called program again after the basic list has been exited. During this new call, the runtime environment supplies the fields of the selection screen between the events INITIALIZATION and AT SELECTION-SCREEN OUTPUT with the previous input values. The program call is not complete until the user exits the selection screen processing by choosing Back, Exit, or Cancel.
For each event, the respective event block is executed in the called program, if it is implemented.
If the called program is linked with a logical database (which is basically a collection of subroutines that provides other ABAP programs with data from the nodes of a hierarchical tree structure), the runtime environment calls for most of the steps listed above one or more subroutines of the logical database.
So if you ever wondered, why the heck values, that you have assigned to input fields of the selection screen during LOAD-OF-PROGRAM or INITIALIZATION, are superseded by other values – the above program flow tells you why!*
*If you definitely want to fill selection screen fields with your own values, you must do so during the
event AT SELECTION-SCREEN OUTPUT, i.e. during PBO of the selection screen, of course.