
Writing a Multiline Object Reference into a Container
Prerequisites
The following prerequisites must be fulfilled in order to write a multiline object reference into a container:

These prerequisites are always fulfilled if you are in the
Procedure
DATA <ObjectList> TYPE SWC_OBJECT OCCURS 0.
The internal table created does not have a table header. You fill it by creating each object reference individually and appending them to the table.
DATA <Object> TYPE SWC_OBJECT.
SWC_CREATE_OBJECT <Object> <ObjectType> <ObjectKey>.
APPEND <Object> TO <ObjectList>.
SWC_SET_TABLE <Container> <ContainerElement> <ObjectList>.

Upper and lower case are not distinguished for the container element ID. If the container is used in the binding of a workflow, you must ensure that a container element of the same name is defined in the container definition.
SWC_CONTAINER_TO_PERSISTENT <Container>.

You need persistent object references if the container is also to be used in another environment. This applies if you pass the container as a parameter in a function call, for example if:
Result
The object references created are runtime references that only exist in the environment of the creating program. These object references are written into the container in a container element. If the container element with this ID is not yet in the container, it is inserted into the container with its value. If there is already a container element with this ID in the container, the old value is overwritten with the new value. If the container is needed in another program context, you must make the object references contained persistent.
Example
The variable
POSITIONLIST (item list) is declared as a multiline object reference.* Type declarations for multiline object reference
DATA POSITIONLIST TYPE SWC_OBJECT OCCURS 0.
The variable
POSITION (item) is declared as an object reference. This variable serves as an auxiliary variable in the processing of the multiline object list.* Type declarations for object reference
DATA POSITION TYPE SWC_OBJECT.
Values are assigned to the internal table
POSITIONKEY (item key). An object reference is created in the variable POSITION for each entry and written into the multiline object reference POSITIONLIST.* Type declaration for the key fields of
* the object "order item"
DATA: BEGIN OF POSITIONKEY,
DOCUMENT LIKE VBAP-VBELN, "sales document
ITEM LIKE VBAP-POSNR, "sales document item
END OF POSITIONKEY.
* Process multiline object reference
SELECT * FROM VBAP
WHERE VBELN BETWEEN '0000002500' AND '0000002600'.
* Fill key fields
POSITIONKEY-DOCUMENT = VBAP-VBELN.
POSITIONKEY-ITEM = VBAP-POSNR.
* Create object reference
SWC_CREATE_OBJECT POSITION 'VBAP' POSITIONKEY.
* Insert object reference into multiline object reference
APPEND POSITION TO POSITIONS.
ENDSELECT.
The multiline object reference
POSITIONLIST is written into the container MY_CONTAINER in the container element Items.* Write multiline object reference to container
SWC_SET_TABLE MY_CONTAINER 'items' POSITIONLIST.
For a further example, see
Implementation Program for a Virtual Attribute.