Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Declaring Data Types →  TYPES →  TYPES - BEGIN OF struct_type 

TYPES - BOXED

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


TYPES comp TYPE struc_type BOXED. 

Effect

This statement defines a substructure comp of a structure as a static box. It can only be located within a structure definition with the additions BEGIN OF and END OF of the statement TYPES, and only at the top component level and not within nested BEGIN OF ... END OF blocks.

struc_type expects a structured data type. This can be a program-local structure, a visible structured type of a class or of a global interface, or a structure from ABAP Dictionary, and can contain boxed components.

Static boxes support initial value sharing. Here, the structure is not saved in the higher level context itself. Instead, an internal reference that points to the actual structure is saved in place of the component. This makes a static box a deep component.


Notes

  • A structure with a static box is a deep structure and the relevant restrictions apply.
  • The addition BOXED defines the static box with reference to its context (structure or class). A data type declared using a direct TYPE reference or LIKE reference to a static box is assigned its data type but is not a static box itself.
  • When a static box is applied from one structure to another structure using the statement INCLUDE TYPE|STRUCTURE, its static attribute is also applied.
  • If a nested structure whose static boxes already contain static boxes needs to be created, this is only possible if each substructure in question exists as a standalone type. You cannot specify BOXED for substructures that exist as a result of nesting of TYPES BEGIN OF ... TYPES END OF.
  • The addition BOXED can also be used in the statement DATA to declare a structured attribute of a class or an interface.

Example

The following section shows how the addition BOXED can be used with the statement TYPES. In a structured type t_struc2, a substructure 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.