ABAP Keyword Documentation → ABAP − Reference → Declarations → Declaration Statements → Data Types and Data Objects → Declaring Data Objects → DATA
DATA - BOXED
Other versions: 7.31 | 7.40 | 7.54
Syntax
DATA struc TYPE struc_type BOXED.
Effect
This statement defines a structured attribute of a class or an interface as a static box. It can only be located in the declaration section of a class or an interface and only at the highest level.
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 directTYPE
reference orLIKE
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. -
The addition
BOXED
can also be used in the statementTYPES
to declare a substructure of a nested structured data type.
Example
The following section shows how the addition BOXED
is allowed to be used with the statement [CLASS-]DATA
. In a class, it declares a static structure struc1
and a structured instance attribute struc2
as a static box.
CLASS c1 DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF t_struc,
comp1 TYPE c LENGTH 100,
comp2 TYPE n LENGTH 100,
END OF t_struc.
PRIVATE SECTION.
CLASS-DATA struc1 TYPE t_struc BOXED.
DATA struc2 TYPE t100 BOXED.
ENDCLASS.