ABAP Keyword Documentation → ABAP - Reference → Declarative statemnts → Data Types and Data Objects → Declaring Data Types → TYPES → TYPES - BEGIN OF
INCLUDE - TYPE, STRUCTURE
Other versions: 7.31 | 7.40 | 7.54
Syntax
INCLUDE { {TYPE struc_type} | {STRUCTURE struc} }
[AS name [RENAMING WITH SUFFIX suffix]].
Extras
1. ... AS name
2. ... RENAMING WITH SUFFIX suffix
Effect
These statements can only be declared within a structure definition with the additions BEGIN
OF and END OF
of the statements
TYPES, DATA
,
CLASS-DATA
and STATICS
.
It copies all the components of the structured type struc_type
or the structure
struc
at the specified point in to the current structure definition. The INCLUDE
statement does not create a
substructure, that is,
the components are inserted as if they would be listed individually in place of the INCLUDE
statement.
struc_type
can be a local, structured type, a visible structured type of
a global class or a global interface, or a structure from the ABAP Dictionary. struc
must be a structure of the same program or a visible attribute of a global class or global interface.
Notes
-
The
INCLUDE
statement described here must no longer be used for the following reasons:
- If further structure components are to be added to existing components using the
INCLUDE
statement of if multipleINCLUDE
statements are used in a structure, then there can be syntax errors due to name conflicts. This is particularly problematic if structures are to be inserted that are not defined in the same program and which are to be changed at a later date.
- The embedded structures cannot be addressed as such without restrictions.
- The necessary metadata is created again for every component of an embedded structure, whereas the metadata for the components of a substructure are only stored once when defining the substructure.
- In contrast to real substructures, structures embedded using
INCLUDE
cannot be declared as static boxes during embedding.
INCLUDE
statement, real
substructures are to be
formed when possible. At the very least you should use the addition RENAMING WITH
SUFFIX to avoid naming conflicts. This recommendation applies for embedding structures in the ABAP Dictionary where the structures of database tables cannot contain any real substructures. -
Outside of ABAP objects, flat structures, database tables, or
views of the ABAP Dictionary can also be specified for
struc
with the additionSTRUCTURE
. -
In constant structures defined with
CONSTANTS
, no components can be embedded withINCLUDE
as these cannot be assigned a start value. -
With regard to their alignment, structures integrated with
INCLUDE
behave like substructures, meaning that there can be alignment gaps before or after the last component. These do not appear if the components are declared directly. -
When a static box is copied from a structure to another, it is copied as a
boxed component.
Addition 1
... AS name
Effect
By specifying the name name
after the addition AS
you can either address all components of the embedded structure struc_type
or struc
together using the name name
or individual components using the structure component selector (-
).
Note
A name name
specified with AS name
is only used
for additional addressing purposes and is ignored in statements such as
MOVE-CORRESPONDING
or
SELECT INTO CORRESPONDING. An component renamed with RENAMING WITH SUFFIX
actually has this name and is therefore not ignored.
Addition 2
... RENAMING WITH SUFFIX suffix
Effect
With the addition RENAMING WITH SUFFIX
every individual component is renamed
by adding the suffix
, whereby naming conflicts between components of the same name can also be avoided. suffix
must be specified directly.
Note
Using the RENAMING WITH SUFFIX
addition makes it possible to embed an individual structure multiple times.
Example
In this example the structure week
is defined by repeatedly copying the
components on the structured type t_day
. The components of week
are all at the same level and can be declared as follows: week-work_mon
,
week-free_mon
, week-work_tue
, and so on. Alternatively,
the following addressing is also possible: week-monday-work
, week-monday-free
, week-tuesday-work
, and so on.
TYPES: BEGIN OF t_day,
work TYPE c LENGTH 8,
free TYPE c LENGTH 16,
END OF t_day.
DATA BEGIN OF week.
INCLUDE TYPE t_day AS monday RENAMING WITH SUFFIX _mon.
INCLUDE TYPE t_day AS tuesday RENAMING WITH SUFFIX _tue.
INCLUDE TYPE t_day AS wednesday RENAMING WITH SUFFIX _wed.
...
DATA END OF week.