Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Types and Objects - Overview →  Details of Special Data Types or Data Objects 

Structures

Structures are data objects (comprised of components of any data type) that are saved one after the other in the memory. The data type of a structure is a structured type or a structure defined in the ABAP Dictionary, including database tables and views.

In a program, a structured type or structure is created using the additions BEGIN OF ... END OF of the statements TYPES, DATA, and so on. They can also be created dynamically using the methods RTTC.

Other versions: 7.31 | 7.40 | 7.54

Types of Structures

Structures are named as follows (depending on the type of the component):

  • Flat structures do not contain any deep components. They only contain components with flat data types, such as elementary types c, n, d, decfloat16, decfloat34, t, f, i, p, x and b, s or alternatively structures with these types.
  • Flat character-like structures are flat structures that contain only character-like components.
  • Nested structures contain at least one substructure. A nested structure is flat or character-like, depending on the attributes of all components.
  • Deep structures contain at least one deep component, at any nesting level. Possible deep components include strings, internal tables, boxed components, data or object references.

A structure that contains static or dynamic components is (formally) a static or dynamic data object, respectively.

The following figure illustrates a deep structure.

Mapping


Note

The term "nested structure" must not be confused with the term "deep structure". A nested structure is flat if it only contains flat components and subcomponents. A nested structure is deep when it has at least one deep component or subcomponent.

Boxed Components

The substructures of nested structures and structured components of classes or interfaces can be declared as boxed components.

Using Structures

Structures are addressed either fully or by component, at appropriate operand positions. The structure component selector (-) is used for the latter case. Special conversion rules apply to assignments that involve structures.

Flat character-like structures differ in that they can be used like character-like data objects and included in the generic ABAP type clike. They can be placed in all operand positions where elementary character-like data objects are possible. The ABAP runtime environment then interprets the structure as an elementary field of the type c in the length of the structure.


Note

In obsolete non-Unicode programs, any flat structures can be used like character-like data objects.

Using Deep Structures

The data content of deep structures is not saved completely within the memory bounds of the structure and the deep components are just references to the actual data instead. This means that some general restrictions apply when using deep structures (unlike flat structures):

  • Deep structures cannot be used as character-like data objects in operand positions and are not included in the generic ABAP type clike. This applies in particular to structures that contain strings.
  • When data objects are cast with ASSIGN, the type, position in the type of the data object, and the position in the type of the field symbol must match for deep components in deep structures.
  • The work area of Open SQL statements cannot contain any deep components other than strings or LOB handles
  • The target or source field of the statements OPEN DATASET and TRANSFER cannot be a deep structure.
  • Internal tables with a deep row type cannot be passed to a TABLES parameter in a Remote Function Call. Deep structures can be passed to the other parameters, as long as they do not contain any reference variables.


Note

These restrictions are particularly important if single components in existing flat character-like structures are converted to strings, which makes the entire structure deep.

Using Deep ABAP Dictionary Structures

The same restrictions apply to deep structures defined in ABAP Dictionary as to deep structures defined in ABAP programs. Further restrictions apply only when the following language elements forbidden in classes (in which only flat ABAP Dictionary structures can be specified) are used:

  • Statement TABLES for table work areas.
  • Obsolete use of LIKE instead of TYPE as a reference to data types in ABAP Dictionary with type declarations and typings.

Programming Guideline

Do not include components from structures


Note

When a dynpro field references a component of a structure in ABAP Dictionary, it is important that the structure is declared using TABLES to enable a data transport between the dynpro and the ABAP program; only flat structures are suitable here.

Maximum Size of Structures

The memory used directly by a structure cannot exceed a certain size, including any alignment gaps. This size is defined so that a given structure in a non- Unicode system, in which each character uses one byte can use a maximum of 64 KB. In a Unicode system, the maximum amount of memory that can be used can be more. This depends on the number of characters and the character set used. A deep component only contributes the size of the reference (8 bytes) to the directly used memory.