ABAP Keyword Documentation → ABAP - Reference → Declarations → Declaration Statements → Data Types and Data Objects → Declaring Data Types → TYPES
TYPES - BEGIN OF struct_type
Other versions: 7.31 | 7.40 | 7.54
Syntax
TYPES BEGIN OF struc_type.
...
TYPES comp ...
TYPES comp TYPE struc_type BOXED.
INCLUDE TYPE|STRUCTURE ...
...
TYPES END OF struc_type.
Effect
Defines a structured type struc_type
. This is introduced using a TYPES
statement with the addition BEGIN OF
and must finish with a TYPES
statement with the addition END OF
.
The following can be included between these TYPES
statements:
-
Any
TYPES
statements, in particular further closed structure definitions. -
The definition of static boxes using
BOXED
. -
The statements
INCLUDE TYPE
andINCLUDE STRUCTURE
for including components from other structures.
No structured types can be created that do not have at least one component.
The TYPES
statements within the statements BEGIN OF
and END OF
define the components of the structured type struc_type
.
If a component is a structured type or if a new structured type is defined within a structure using
BEGIN OF
and END OF
, substructures are created. A structure with substructures is known as a nested structure.
A component of struc_type
cannot be declared with reference to struc_type
itself . If the name struc_type
is specified after TYPE
in the declaration of a component, the next type of this name is searched for in a higher
visibility area, and used if found. If a more global type of this name does not exist, a syntax error occurs.
If a component is created as a table type, this type cannot be generic.
The statement INCLUDE
defines
components of the structured type struc_type
by using the components of a differently structured type or an existing structure at the same level.
The components of a structured type are divided using the name struc_type
and the name of the component, and addressed using the structure component selector
(-
).
Notes
-
The value
operator
VALUE
can be used to construct the content of structures. -
A structure type is always fully specified. There is no generic structure type.
Example
This example defines two structured types, street_type
and address_type
.
address_type
contains structured types as components. The definition of zipcode_type
shows the access to substructures.
TYPES: BEGIN OF street_type,
name TYPE c LENGTH 40,
no TYPE c LENGTH 4,
END OF street_type.
TYPES: BEGIN OF address_type,
name TYPE c LENGTH 30,
street TYPE street_type,
BEGIN OF city,
zipcode TYPE n LENGTH 5,
name TYPE c LENGTH 40,
END OF city,
END OF address_type.
TYPES zipcode_type TYPE address_type-city-zipcode.