ABAP Keyword Documentation → ABAP - Reference → Declarative statemnts → Data Types and Data Objects → Declaring Data Objects → DATA
DATA - BEGIN OF
Other versions: 7.31 | 7.40 | 7.54
Syntax
DATA BEGIN OF struc [READ-ONLY].
...
INCLUDE TYPE|STRUCTURE ...
...
DATA END OF struc.
Effect
The declaration of a new struc
structure. It is initiated using a DATA
statement with the BEGIN OF addition and must be ended using a DATA statement with the END OF addition.
These two DATA statements can include any
-
DATAstatements, particularly further closed structures, -
and the statements
INCLUDE TYPEandINCLUDE STRUCTURE.
The meaning of these statements is the same as in the definition of structured data types in section
TYPES - BEGIN
OF. Here, however, it is used to generate a bound structured data type. A structure cannot be created without at least one component.
A component of type struc cannot itself be declared by means of reference
to struc. If the name struc is specified after LIKE when a component is declared, the system searches for the next object of this name in a higher
visibility section and uses it if found. If no more global objects exist with this name, then a syntax error occurs.
Notes
-
The
READ-ONLYaddition is only possible for the whole structure and not for individual structure components (comp). -
A structure cannot have the name
textsince this is reserved for addressing text symbols. -
The
BOXEDaddition cannot be specified betweenDATA BEGIN OFandDATA END OFwhen components are declared. Static boxes in structures can only be defined withTYPES. -
In an obsolete variant, you can also specify
text field literals or the
spaceconstant as anonymous components betweenBEGIN OFandEND OF. -
The use of the
OCCURSaddition to define standard tables with structured row types is obsolete.
Example
In this example, a structure (spfli_struc) is declared with an elementary component
(index) and a substructure
( spfli_wa). The SELECT loop shows a possible use of the nested structure.
DATA: BEGIN OF spfli_struc,
index TYPE i,
spfli_wa TYPE spfli,
END OF spfli_struc.
SELECT *
FROM spfli
INTO spfli_struc-spfli_wa.
spfli_struc-index = spfli_struc-index + 1.
WRITE: / spfli_struc-index,
spfli_struc-spfli_wa-carrid,
spfli_struc-spfli_wa-carrid.
ENDSELECT.