INCLUDE TYPE 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 thestatements TYPES, DATA,
CLASS-DATA, CONSTANTS,
and STATICS. It transfers all components of the structured
data type s of the same program or from the ABAP Deictionary at the specified point into the current structure definition.
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.
Note
You should no longer use the INCLUDE
TYPE statement simply to define structures whose type is created with reference to existing
structures. Use the constructions below instead. You should only use INCLUDE
TYPE 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
TYPE s.
DATA: ...
END OF rec.
you should use
DATA: BEGIN OF rec,
...
rec
LIKE s,
...
END OF rec.
so that
s can be addressed as a substructure of rec.
Since you can define nested data structures (i.e. structures with sub-structures) starting
from Release 3.0, you should use INCLUDE TYPE only if you want to introduce types in a program first and nested structures in a later step.
... 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 TYPE
as a single entity using the group name name1. 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.
TYPES: BEGIN OF rec1,
f1(1) TYPE C,
f2 TYPE I,
END OF rec1.
TYPES:
BEGIN OF rec2.
INCLUDE TYPE rec1 AS g RENAMING
WITH SUFFIX _g.
INCLUDE TYPE rec1 AS h RENAMING WITH SUFFIX _h.
TYPES: END OF rec2.
DATA: str TYPE rec2.
The structure
str
consists of four components
str-f1_g, str-f2_g,
str-f1_h and str-f2_h.
Using the group component str-g you can address the first
two components; you can then address the latter two using str-h These substructures are of the type rec1.