INCLUDE STRUCTURE s.
1. ... AS
name1
2. ... AS name1 RENAMING WITH SUFFIX name2
This statement can only be used within a structure definition with the additions
BEGIN OF and END OF
to the statements TYPES, DATA,
CLASS-DATA, CONSTANTS,
and STATICS. It transfers all components of the structure
s at the specified point into the current structure definition.
s must be a structure of the same program or a flat structure in the ABAP Dictionary. The latter is only possible outside classes.
Note, especially when using statement chains (colon and comma), that INCLUDE
is a seperate statement and not an addition to the statements
DATA, TYPES and so on.
You should no longer use the INCLUDE STRUCTURE statement
simply to define structures whose type is created with reference to existing structures. Use the constructions
below instead. You should only use INCLUDE STRUCTURE with
the AS additions that allow you to perform offset/length addressing on structures.
A data definition:
DATA BEGIN OF rec.
INCLUDE STRUCTURE s.
DATA END OF rec.
should be replaced with:
DATA rec LIKE s.
Even if the structure rec to be defined contains additional components, instead of:
DATA: BEGIN OF rec,
... .
INCLUDE
STRUCTURE s.
DATA: ...
END OF rec.
you should use
DATA: BEGIN OF rec,
...
rec
LIKE s,
...
END OF rec.
so that s can be referenced as a sub-structure of rec.
Although "INCLUDE STRUCTURE subRec." breaks up the sub-structure
s into its components, the alignment
of s is retained. This means that padding fields may be
inserted before the first and/or before the last component of s in rec.
... AS name1
You can address the components included in INCLUDE STRUCTURE as a single entity, under the group name name1.
Group components are only visible if they are dddressed explicitly by name. The applies for example to the following situations and statements:
The following statements do not take group components into account:
... AS name1 RENAMING WITH SUFFIX name2
You can address the components included in INCLUDE STRUCTURE
as a single entity using the group name name1. The behavior
is the same as in addition 1. When the components of the structure s
are included, the component names are renamed by appending the name name2.
This allows you to include structure s more than once.