Get Example source ABAP code based on a different SAP table
Filling a Structure The example demonstrates the filling of a nested structure.
ABAP_SOURCE_CODE DEMO CL_DEMO_STRUCTURE_FILLING
ABAP_DESCRIPTION In this example, the structure from the executable example Declaring a Nested Structure> is defined with TYPES>> as the data type address_type> and used for the data objects addr> and address>. A separate structure type is also defined for each of the substructures. If a structure is declared with the statement DATA> by reference to a structure type as shown here, the addition VALUE>> cannot be used. Instead, the structure must be filled by accessing the components. In particular, this also applies to the frequently occurring reference to structures of the ABAP Dictionary. There are mainly two ways for doing this:
In the first part of the method main>, the structure addr> is filled using the structure component selector. The component name> is assigned a prefilled structure. In the components street > and city>, the components that are nested there are accessed.
In the second part of the method main>, the structure address > is filled with the value operator VALUE>>, but the structure itself is created using an inline declaration. The parentheses after VALUE> show different options for accessing the components of substructures. Either the structure component selector is used again in the same way as for the substructure name>, or additional VALUE> operators are nested, such as for street> and city>. The content of both structures is the same. The value operator VALUE> represents the modern way, where the need of expressing all the component names explicitly is replaced by the use of parentheses.