Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Declaring Data Objects →  DATA 

DATA - BEGIN OF struc

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


DATA BEGIN OF struc [READ-ONLY]. 
  ...
   INCLUDE TYPE|STRUCTURE ...
  ...
DATA END OF struc.

Effect

Declares a new structure struc. This starts with a DATA statement with the addition BEGIN OF and must end with a DATA statement with the addition END OF.

The following can be included between these DATA statements:

The meaning of these statements is the same as in the definition of structured data types in the section TYPES - BEGIN OF, but here it is used to generate a bound structured data type. No structure can be created without at least one component.

A component of type struc cannot be declared by referencing struc itself. If the name struc is specified after LIKE in the declaration of a component, the next object of this name is searched for in a higher visibility area, and used if found. If a more global object of this name does not exist, a syntax error occurs.


Notes

  • The addition READ-ONLY can only be used for whole structures and not for individual structure components comp.
  • A structure called text cannot have any components with three-character names, since these are reserved for addressing text symbols. It is best never to call a structure text and avoid any conflicts with text symbols.
  • The BOXED addition cannot be specified between DATA BEGIN OF and DATA END OF when declaring components. Static boxes in structures can only be defined with TYPES.
  • The value operator VALUE can be used to construct the content of structures.
  • In an obsolete variant, text field literals or the constant space can be specified between BEGIN OF and END OF as anonymous components.
  • The use of the addition OCCURS for defining 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. 
  cl_demo_output=>next_section( |{ spfli_struc-index }| ). 
  cl_demo_output=>write_data( spfli_struc-spfli_wa ). 
ENDSELECT. 
cl_demo_output=>display( ).