Components of a structure can be defined by including the components of other structures in ABAP Dictionary, including database tables or views. These included structures are known as include structures (or includes for short). From a technical perspective, the structure in which an include structure is included references the included structure and is modified accordingly whenever changes are made to this structure. An include structure can itself contain include structures, with the maximum nesting depth being nine includes.
When an include structure is included, all components of an existing structure are added to the including structure as a replacement for a component. No substructure is created, which means that the components are inserted as if they were specified individually at this position and they are handled like directly defined components. Regular components and include structures can be combined as required.
When a structure is included as an include structure, it can be assigned a name of a group and a three-character suffix.
- In ABAP programs, the name of a group is an additional addressing option for data objects declared
with reference to the structure. All components of the included structure can be addressed together using this name or individual components can be addressed using the structure component selector
-) after the name.
- A suffix is appended to the the component name to rename each component and avoid naming conflicts between components. The original name of a component of an include structure included in a structure with a suffix cannot have more than 27 characters.
Group names and suffixes are assigned in the same way as with the additions AS name
[RENAMING WITH SUFFIX suffix] of the statement
INCLUDE TYPE in ABAP programs. Unlike in the statement
INCLUDE TYPE, an include structure in ABAP Dictionary can have a suffix without a specified name.
The fields of an included include structure are still part of the structure. They can only be edited using the structure and any changes made to the structure are applied to all including structures. The fields of an included include structure can also be transformed to direct fields of the including structure that are then no longer associated with the originally included structure.
7.31 | 7.40 | 7.54
- The potential for naming conflicts between components when including structures makes these actions highly error-prone, particularly in any enhancements made to the included structure. If possible, substructures should be used instead. If this is not an option (for example, in database tables), suffixes should be used to avoid naming conflicts.
- Including structures should not be confused with the adding of components as performed in ABAP Dictionary. Here, the definition of the components is simply copied to a different structure and no binding is persisted. In the same way, an existing include can be resolved to individual component definitions.
- The name of a group is just an additional addressing option and does not resolve any naming conflicts. In particular, group names in statements like MOVE-CORRESPONDING or SELECT INTO CORRESPONDING are ignored. Components renamed with a suffix, on the other hand, really do have this name and are not ignored.
The structure DEMO_WEEK includes the structure DEMO_DAY five times as an include structure with group names and suffixes. The program DEMO_INCLUDE_STRUCTURE shows how its components can be accessed in ABAP.