Writing a Multiline Object Reference into a Container (BOR) 
The following prerequisites must be fulfilled in order to write a multiline object reference of a classical object (BOR) into a container:
The container must have been created and initialized.
For function modules, the include file <CNTN01> must be incorporated in the program. For ABAP classes, the include files <CNTN02> and <CNTN03> must be incorporated. For more information, see Macro Instructions for Processing a Container.
Note
These prerequisites are always fulfilled if you are in the implementation program. The container is then addressed with the name CONTAINER.
The concatenated key of the object must be available in a variable (designated as object key here).
Create a variable for the multiline object reference. Use the following command to do this:
DATA <Object list> 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.
Create a variable for an object reference. Use the following command to do this:
DATA <Object> TYPE SWC_OBJECT.
Create the first object reference. Use the following command to do this:
SWC_CREATE_OBJECT <Object> <Objecttype> <Objectkey>.
Append the object reference to the table. Use the following command to do this:
APPEND <Object> TO <ObjectList>.
Repeat the previous two steps until the table is full.
Write the multiline object reference into the container. Use the following command to do this:
SWC_SET_TABLE <Container> <ContainerElement> <ObjectList>.
Caution
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.
Make the object reference persistent. Use the following command to do this:
SWC_CONTAINER_TO_PERSISTENT <Container>.
Note
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:
You want to evaluate or change the container as an event container in a check function module or receiver type function module
You prepare the container as an event container and use it as a parameter of the function modules SWE_EVENT_CREATE or SAP_WAPI_CREATE_EVENT.
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.
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.
Syntax
* Typdeklarationen für die Schlüsselfelder des
* Objektes "Position eines Auftrags"
DATA: BEGIN OF POSITIONKEY,
DOCUMENT LIKE VBAP-VBELN, "Verkaufsbeleg
ITEM LIKE VBAP-POSNR, "Verkaufsbelegposition
END OF POSITIONKEY.
* mehrzeilige Objektreferenz bearbeiten
SELECT * FROM VBAP
WHERE VBELN BETWEEN '0000002500' AND '0000002600'.
* Schlüsselfelder füllen
POSITIONKEY-DOCUMENT = VBAP-VBELN.
POSITIONKEY-ITEM = VBAP-POSNR.
* Objektreferenz erzeugen
SWC_CREATE_OBJECT POSITION 'VBAP' POSITIONKEY.
* Objektreferenz in mehrzeilige Objektreferenz einfügen
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.