START-OF-SELECTION

Short Reference

Syntax

START-OF-SELECTION.

Effect:

This event keyword defines an event block for which the event is triggered by the ABAP runtime environment during the flow of an executable program and before any selection screens are processed.

In an executable program, all statements that are not declarations and that are listed before the first explicit processing block, or if the program does not contain any explicit processing blocks, then all functional statements of the program, are assigned to an implicit event block START-OF-SELECTION, which is inserted before any START-OF-SELECTION event blocks.

If the program is linked to a logical database, preparatory tasks can be performed at START-OF-SELECTION before the logical database imports the data. If the program is not linked to a logical database, this event block becomes a type of "main program" from which procedures or screens are called.

Example

The following are three executable programs with exactly the same functionality:

The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.

REPORT test_start_of_selection.

DATA text TYPE string.

START-OF-SELECTION.
  text = `Hello World!`.
  WRITE text.

In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.

REPORT test_start_of_selection.

DATA text TYPE string.

text = `Hello World!`.

START-OF-SELECTION.
  WRITE text.

In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.

REPORT test_start_of_selection.

DATA text TYPE string.

text = `Hello World!`.
WRITE text.

The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:

REPORT test_start_of_selection.

DATA text TYPE string.

START-OF-SELECTION.
  text = `Hello World!`.

START-OF-SELECTION.
  WRITE text.

This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.

Example:

For more information on START-OF-SELECTION, see the example for reporting results.