Validity and Visibility

The context of a declarative statement in the source text of a program determines the validity and visibility of the declared comporent. In ABAP programs there are three contexts in which data types and data objects can be declared:

All contexts see the program-independent type definitions of the ABAP Dictionary and the type definitions and data declarations in the public visibility areas of global classes. Local declarations, however, hide global declarations with the same name. In statements, in which a dynamic specification of a data type, a class or an interface is possible, the hiding of a global type by a local type can be cancelled by specifying an absolute type name.

In addition to context-dependent visibility, the position of the declaration in the source text also plays a role. In a statement of an ABAP program only previous declarations are visible, regardless of the context. In order that the order in the program corresponds with the context-dependent visibility, all global declarations of a program should be listed at the start of the source text before the first processing block, and all local declarations should be listed after the introduction of a procedure. The definition of an interface and the declaration section of a class belong to the global declarations in this view. Note that reference variables that refer to a class cannot be declared until after the declaration of the class. The implementation section, in contrast, belongs to the processing blocks.

Note

All data declared in the declaration sectino of an ABAP program is global to the program. With the exception of the event blocks GET[LATE] and AT SELECTION-SCREEN, all data declared within event blocks and dialog modules is global to the program. The data declared in the above event blocks is local to these event blocks. Data that is declared between discrete processing blocks is also global for the program.