Each ABAP program consists of an introductory program part, a global declaration part and a number of processing blocks which implement different functions depending on the application (procedures, dialog modules, event blocks). Processing blocks are inseparable syntactical modularization units which cannot comprise any other processing block. Normally they contain several ABAP statements which are organized into statement blocks by means of control structures.
The following diagram shows the structure of an ABAP program:
Every independent ABAP program begins with an introductory statement which depends on the program type. Some of these statements have additions which you can use to make program settings.
In every ABAP program, the introductory program part is followed by the declaration part for global data, classes, and selection screens. This consists of:
· All declaration statements for global data. Global data is visible in all internal processing blocks. You define it using declarative statements that appear before the first processing block, in dialog modules, or in event blocks. You cannot declare local data in dialog modules or event blocks except the following:
· All selection screen definitions.
· All declarations of internal class definitions and interfaces.
Declaration statements which occur in procedures (methods, subroutines, function modules) form the declaration part for local data in those processing blocks. This data is only visible within the procedure in which it is declared.
You can list the processing blocks of an ABAP program in the source code of the program in any sequence you like below the global declaration part as they are not executed consecutively. Only the source code contained in a statement block is executed sequentially.
The following types of processing blocks are available which can be exited prematurely using the RETURN statement.
· Dialog modules (no local data area)
· Event blocks (no local data area, with two exceptions)
· Procedures (methods, subroutines and function modules with their own local data area).
Whereas dialog modules and procedures are enclosed in the ABAP keywords which define them, event blocks are introduced with event keywords and concluded implicitly by the beginning of the next processing block.
All ABAP statements (except declarative statements in the declaration part of the program) are part of 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.