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.
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
sor 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.
The following figure illustrates a deep structure.
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.
The substructures of nested structures and structured components of classes or interfaces can be declared as boxed components.
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
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.
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):
- Substring access using offset/lengths is not possible for deep 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
- Internal tables with a deep row type cannot be passed to a
TABLESparameter in a Remote Function Call. Deep structures can be passed to the other parameters, as long as they do not contain any reference variables.
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:
TABLESfor table work areas.
- Obsolete use of
TYPEas a reference to data types in ABAP Dictionary with type declarations and typings.
- Obsolete use of
- Obsolete forcing of a structure
STRUCTUREto field symbols or interface parameters of function modules or subroutines.
When a dynpro field references a component of
a structure in ABAP Dictionary, it is important that the structure is declared using
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.