SAP INCLUDING STRUCTURES - Guide

Get Example source ABAP code based on a different SAP table
  


GUIDELINES 6.4

Including Structures

ABAP_BACKGROUND
In the program-internal design of structures with the BEGIN OF and END OF additions of the TYPES and DATA ABAP Code Snippet statements to integrate all components of another structure with the current structure at this place without creating a specific su bstructure. 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.

ABAP_RULE
Do not include components from structures
ABAP Code Snippet when declaring a structure. If required, you can include the components in a real substructure.

ABAP_DETAILS
The reasons for this rule are the following:
The integration of components can lead to naming conflicts. This is particularly problematic if structures of other contexts are integrated and changed retroactively.
Although it is possible to assign a name, the integrated structures cannot be addressed as such without restrictions. The necessary internal type information is individually stored for each integrated component. For the components of a substructure, however, this information is stored only once for the substructure
In contrast to real substructures, structures integrated using ABAP Code Snippet component is a structured component, which is managed through an internal reference and thus supports initial value sharing. This can considerably reduce the memory requirements for rarely filled components.
The statement cancels a chained statement that has been created with BEGIN OF and END OF .
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,
...
ABAP Code Snippet
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.