Program Structure
- The functions of an ABAP program are implemented in processing blocks. Processing blocks are defined using
modularization statements. You can use
declarative statements in processing blocks of the type
procedure to define local data types and data objects. The other processing blocks do not have a local
data area, and any declarative statements
apply to the program globally. Methods play a special role here: Methods are processing blocks that
have to be implemented within the implementation section of their class. The order of the processing
blocks or implementation sections is irrelevant for program execution, but should be designed to make the program easy to read.
- Following the introductory statement, every program contains a global declaration section, in which you implement the
definitions and declarations that are valid and visible in the
entire program. This includes the declaration of data types and data objects, as well as the definition
of interfaces or the declaration section of classes in ABAP Objects. The definitions of interfaces and
classes contain the declarations of their components. While the order of the individual definitions
and declarations is not specified, you have to take into account that an ABAP statement can only refer
to existing definitions and declarations. For example, a reference variable can only refer to a previously defined class, which in turn can only implement a previously defined interface. Once you introduce a
procedure, you can declare the data types and data objects that will be visible within that procedure.In the broadest sense, the declaration of data types also includes the
typing of objects whose data type is undetermined when the program is written.
- All the other statements of an ABAP program are implementation statements, which can always be assigned to a
processing block. You use the implementation
statements to implement the functions of a processing block. The functions of all processing blocks are largely implemented using the same statements.
- Since ABAP is a language that has grown over time, it contains several
obsolete additions to statements that have been replaced with improved
language constructs, but which have not been eliminated in order to ensure downward compatibility. In
ABAP Objects - that is, in the implementation of methods -, almost all of the obsolete language elements
will fail syntax checks. In general, you should no longer use these language elements in new programs, but you may to encounter them in older programs.