Program Construction

One of the particular features of ABAP programs is their modular form. The smallest modularization unit in an ABAP program is a processing block, consisting of ABAP statements (usually several). You cannot nest processing blocks. An ABAP program is executed by calling the individual processing blocks.

Each ABAP program consists of the following two parts:

Declaration Part for Global Data and Classes

The first part of an ABAP program is the declaration part for global data and classes. This consists of:

Declaration statements which occur in routines form the declaration part for local data in those processing blocks. This data is only visible within the routine in which it is declared.

Container for Processing Blocks

The second part of an ABAP program contains all of the processing blocks for the program. The following types of processing blocks are allowed:

Whereas dialog modules and routines are enclosed in the ABAP keywords which define them, event blocks are introduced with event keywords and conclude before the beginning of the next processing block (see Statements and Keywords).

Each executable ABAP program (report) contains at least one processing block. All executable ABAP statements (apart from the declarative statements in the declaration part) belong to a processing block. Non-declarative ABAP statements, which occur between the declaration of global data and a processing block are automatically assigned to the START-OF-SELECTION processing block. ABAP statements which occur between processing blocks are not assigned to a processing block and are never executed.

Calling Processing Blocks

You can call processing blocks either from outside the ABAP program or using ABAP commands which are themselves part of a processing block. Calling event blocks is different from calling other processing blocks for the following reasons:

Event blocks are called by events. An event can be a user action on a selection screen or a list, or it can be generated by a system program. You do not need to define event blocks for all possible events (in contrast to the fact that a subroutine call requires the corresponding subroutine to exist). An event triggers a call to its associated event block if one exists in the ABAP program. Otherwise, the event is ignored. This ensures that while an ABAP program may react to a particular event, it is not forced to do so.