Problem solve Get help with specific problems with your technologies, process and projects.

ABAP Geek 4 -- The mystery of SUBMIT unveiled

This tip is the fourth in the 'ABAP Geek' series of weblogs from SDN. Learn more about program execution here.

In ABAP Geek 3 , 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.

Executing Executables

Executable programs are only directly executable from the end user's perspective. Whenever an executable program is started using System-> Services ->Reporting or a report transaction, 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 basic list 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 J). 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 have not seen it yet.

What really happens after SUBMIT

The SUBMIT statement loads the called program in a separate internal session (see an upcoming Weblog 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:

1. Event LOAD-OF-PROGRAM (a kind of program constructor, always triggered when a program is loaded into memory)

2. The start values defined using the DEFAULT addition in the statements PARAMETERS and SELECT-OPTIONS are passed to the relevant data objects. The start values of all other data objects are set before LOAD-OF-PROGRAM.

3. Reporting event INITIALIZATION

4. 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.

5. Reporting event START-OF-SELECTION.

6. Different GET events (normally processed in loops), if the called program is linked with a logical database.

7. Reporting event END-OF-SELECTION.

8. The basic list is called.
If the basic list is empty, the program is exited.
If the basic list is a print 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.

9. 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 ¨C 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.

Horst Keller Horst is a developer in the department NetWeaver Developer Tools ABAP of SAP.

This weblog originally appeared in the SAP Developer Network. To view the original weblog click here . The SAP Developer Network is the central hub for the SAP technology community and is SAP's new collaborative community portal for developers, administrators and consultants. Registration to the SDN community is free.

Dig Deeper on SAP ABAP