Skip to content

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

DATA - BEGIN OF struc

Quick 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 create 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, a search is performed for the next object with this name in a higher visibility section, and used if found. If a more global object with 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 addition BOXED 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 as anonymous components between BEGIN OF and END OF.
  • The use of the addition OCCURS for defining standard tables with structured row types is obsolete.
  • The statements for declaring a structure are usually summarized in a chained statement if possible.

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 += 1. 
  cl_demo_output=>next_section( |{ spfli_struc-index }| ). 
  cl_demo_output=>write_data( spfli_struc-spfli_wa ). 
ENDSELECT. 
cl_demo_output=>display( ).

Executable Examples

Continue

Declaration of a Simple Structure

Declaration of a Nested Structure