TYPES - BOXED
TYPES comp TYPE struc_type BOXED.
This statement defines a substructure
comp of a structure as a
static box. It can only
be used within the relevant structure definition with the
BEGIN OF and
additions of the
TYPES statement and must be at the highest component level and not within nested
BEGIN OF ... END OF blocks.
A structured data type must be specified for
struc_type. This can be a local
program structured type, a visible structured type of a class or a global interface, or a structure from the ABAP Dictionary, and can contain static boxes.
Static boxes support initial value sharing. The structure is not saved in the higher-level context itself. Instead, an internal reference that points to the actual structure is stored in place of the component. A static box is therefore a deep component.
- A structure with a static box is a deep structure and the corresponding restrictions apply.
BOXEDaddition defines the static box with reference to its context (structure or class). A data type that is declared by a direct
LIKEreference to a static box is assigned its data type but is not a static box.
When a static box is copied from one structure to another structure using the
INCLUDE TYPE|STRUCTUREstatement, its static box attribute is also copied.
If you want to create a nested structure whose static boxes already contain static boxes, this is only
possible if each substructure affected exists as an independent type. You cannot specify
BOXEDfor substructures that exist as a result of nested
TYPES BEGIN OF ... TYPES END OF.
BOXEDaddition can also be used in the DATA statement to declare a structured attribute of a class or an interface.
The following section shows the permitted use of the addition
TYPES. In a structured type
t_struc2-comp2 of type
t_struc1 is declared as a static box.
TYPES: BEGIN OF t_struc1,
comp1 TYPE c LENGTH 100,
comp2 TYPE n LENGTH 100,
END OF t_struc1.
TYPES: BEGIN OF t_struc2,
comp1 TYPE string,
comp2 TYPE t_struc1 BOXED,
END OF t_struc2.