ABAP Keyword Documentation →  ABAP Programming Guidelines →  Robust ABAP →  Data Types and Data Objects → 

Including Structures

Background

In the program-internal design of structures with the BEGIN OF and END OF additions of the TYPES and DATA statements, you can use the INCLUDE TYPE or INCLUDE STRUCTURE statements to integrate all components of another structure with the current structure at this place without creating a specific substructure. You can specify a name for shared addressing and a suffix to avoid naming conflicts. The ABAP Dictionary provides the same functionality.

Substructures, in contrast, are formed if the components of a structure themselves are structured. A structure with substructures is known as a nested structure.

Rule

Do not include components from structures

Do not integrate the components of other structures by using INCLUDE when declaring a structure. If required, you can include the components in a real substructure.

Details

The reasons for this rule are the following:

If no real substructures can be formed, you must avoid naming conflicts as far as possible by using suffixes (RENAMING WITH SUFFIX addition). This recommendation also applies to the integration of structures in the ABAP Dictionary, where you cannot always create real substructures (for example, for database tables).

Bad example

The following source code shows the integration of the components of a structure into another structure, which is not recommended according to the above rule.

TYPES:
  BEGIN OF structure_1,
  ...
  END OF structure_1.
TYPES:
  BEGIN OF structure_2,
  ...
  INCLUDE TYPE structure_1 AS sub_structure.
TYPES:
    ...
  END OF structure_2.

Good example

The following source code shows the declaration of a component of a structure as a substructure as recommended in the above rule.

TYPES:
  BEGIN OF structure_1,
   ...
  END OF structure_1.
TYPES:
  BEGIN OF structure_2,
    ...
    sub_structure TYPE structure_1.
    ...
END OF structure_2.