SAP STATIC BOXES



Get Example source ABAP code based on a different SAP table
  



Static Boxes
Static boxes are boxed components whose components are known statically, and which are subject to initial value sharing. Declarations of static boxes generally require less memory for structures that occur multiple times but are rarely used.
The following can currently be declared as static boxes:
Substructures of structured data with the addition BOXED of the statement TYPES.
Structured attributes of classes or interfaces with the addition BOXED of the statement $[CLASS-$]DATA.
A static box can have one of two states:
Initial value sharing As long as none of the actions named in the following point have been executed, initial value sharing applies to a static box. The internal reference refers to a type-dependent initial value of the structure, which is stored exactly once for each ABAP_ASINSTANCE in its PXA. The memory requirement in the ABAP_ISESS is determined only by the internal reference and its administration.
Revoked initial value sharing The following actions revoke initial value sharing for a static box:
Writes to the static box or one of its components.
Assigning the static box or one of its components to a field symbol using ASSIGN.
Addressing the static box or one of its components using a data reference.
Using a static box or one of its components as an actual parameter for procedure calls. The internal reference then refers to an instance of the structure in the current ABAP_ISESS . The memory requirement is the same as for a regular structure plus the administration costs for the internal reference.
In initial value sharing, the memory required for the ABAP_ISESS of a static box is not defined at the start of program execution. However, unlike in real dynamic data objects , the length of a static box is always known statically. Static boxes can be used in the same way as a regular component of the same type. When a structure that contains a static box is accessed, however, it should be ensured that it is a deep component.



Latest notes:

Static boxes can be used to optimize the memory requirement of structures that are used more than once. If, for example, the line structure of an internal table contains substructures, the memory requirement of the substructure accumulates without the use of static boxes for each line, even if the substructure is initial. If static boxes are used, initial substructures do not require multiple memories as long as only reads are performed.
In addition to the optimized memory requirements, static boxes generally have a positive impact on runtime performance, since assignments between components for which initial value sharing is active only require the internal reference (and no additional data) to be copied.
The statements CLEAR and FREE do not affect a static box that has the initial value sharing state like a write statement and the state is retained. On the other hand, once the initial value sharing state is revoked, these statements do not currently free up any memory and provide the local instance of the static box with type-specific initial values instead.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Declaration of a substructure scarr as a static box.
ABEXA 01292
ABAP_EXAMPLE_END