Entering content frameProcedure documentation Writing a Multiline Object Reference into a Container Locate the document in its SAP Library structure

Prerequisites

The following prerequisites must be fulfilled in order to write a multiline object reference into a container:

Note

These prerequisites are always fulfilled if you are in the implementation program. The container is then addressed with the name CONTAINER.

Procedure

  1. Create a variable for the multiline object reference. Use the following command to do this:
  2. 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.

  3. Create a variable for an object reference. Use the following command to do this:
  4. DATA <Object> TYPE SWC_OBJECT.

  5. Create the first object reference. Use the following command to do this:
  6. SWC_CREATE_OBJECT <Object> <ObjectType> <ObjectKey>.

  7. Append the object reference to the table. Use the following command to do this:
  8. APPEND <Object> TO <ObjectList>.

  9. Repeat the previous two steps until the table is full.
  10. Write the multiline object reference into the container. Use the following command to do this:
  11. 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.

  12. 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:

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.

Leaving content frame