Macro Instructions for Processing a Container 

Use

You can use these macro instructions for the following programs:

Processing a container instance includes:

Only the columns Element ID and Value are relevant for this.

When values are assigned to the container no check is made as to whether the elements entered and the data type of their values are in accordance with the container definition. You must ensure that the element IDs and the data types that you use are in accordance with the definition.

A container element ID is always managed internally in upper case. It does not matter whether you use upper or lower case when calling the macro instructions, because the element ID is always converted to upper case before access.

Prerequisites

The include file <CNTN01> must have been included into the program in order to use these macros. Use the following instruction to do this:

INCLUDE <CNTN01>.

Since the include file <OBJECT> already contains the include file <CNTN01> , the include file <CNTN01> cannot be included in an implementation program again.

The container must be declared and initialized with the following macro instructions:

SWC_CONTAINER <Container>. "Declaration
SWC_CREATE_CONTAINER <Container>. "Initialization

For further information, refer to Declaration and Initialization of a Data Structure of a Container.

Features

You can assign the content of a field to a container element or write the content of a container into a field. This content can be multiline, that is, in the form of an internal table. The content of a field can be an elementary data type, a structure or an object reference.

An object reference refers to an object of an object type defined in the Business Object Repository. The key required for unique identification of the object is described there. The key is comprised of one or more key fields. Key fields are, for example, an order number or company code, document number and posting year, which together form a key.

Within the transaction for creating an order, an event is triggered when this order has been successfully created.

The object created is to be made known to a potential receiver of this event. You therefore write a reference to this object described by the key fields of the object type Order into the event container.

Entries for a particular material in the material master data are to be maintained in a workflow step. The role "material administrator" is to have responsibility for this activity.

The role resolution is carried out by a function module provided by the application on the basis of the information about the material. The workflow system passes a container to this function module containing the object reference to the object of the type Material. Within the function module, the object reference is read from the container and the evaluation for determining the selected agent(s) carried out.

Activities

The macros required for reading and writing and their call procedures differ with the content of the container element. Deleting and copying container elements does not vary.

Deleting a container element

SWC_DELETE_ELEMENT <Container> <ContainerElement>.

If the container element does not exist in the container, the error code 1 is returned with SY-SUBRC , otherwise SY-SUBRC has the value 0 .

Copying a container element

SWC_COPY_ELEMENT <SourceContainer> <SourceElement> <TargetContainer> <TargetElement>.

The container element is copied into the target container. If a container element with the same name exists there it is overwritten, otherwise a new container element is created.

Elementary type or structure

Use the macros below to read structures or single variables from a container or to write them into a container.

Writing a field value

SWC_SET_ELEMENT <Container> <ContainerElement> <Value>.

For further information, refer to Writing a Field Value into a Container.

Reading a field value

SWC_GET_ELEMENT <Container> <ContainerElement> <FieldVariable>.

If the container element does not exist in the container, the error code 1 is returned with SY-SUBRC , otherwise SY-SUBRC has the value 0 .

Multiline elementary type or multiline structure

Use the macros below to read multiline structures or multiline variables from a container or to write them into a container.

Writing a multiline field value

SWC_SET_TABLE <Container> <ContainerElement> <Value>.

For further information, refer to Writing a Table into a Container.

Reading a multiline field value

SWC_GET_TABLE <Container> <ContainerElement> <TableVariable>.

If the container element does not exist in the container, the error code 1 is returned with SY-SUBRC , otherwise SY-SUBRC has the value 0 .

Object reference as container element

Use the macros below to read object references from a container or to write them into a container. When an object reference is written into a container, the system:

Writing an object reference

You declare and create an object reference and then write it into the container.

DATA <Object> TYPE SWC_OBJECT.
SWC_CREATE_OBJECT <Object> <ObjectType> <ObjectKey>.
SWC_SET_ELEMENT <Container> <ContainerElement> <Object>.

For further information, refer to Writing an Object Reference into a Container.

Reading an object reference

You declare an object reference, fill it from the container, and can then establish the associated object type and key from the object reference.

DATA <Object> TYPE SWC_OBJECT.
SWC_GET_ELEMENT <Container> <ContainerElement> <Object>.
SWC_GET_OBJECT_KEY <Object> <ObjectKey>.
SWC_GET_OBJECT_TYPE <Object> <ObjectType>.

For further information, refer to Reading an Object Reference from a Container.

Multiline object reference as container element

Use the macros below to read multiline object references from a container or to write them into a container. When an object reference is written into a container, the system:

Writing a multiline object reference

You declare a multiline object reference and a single object reference. You then create each object reference to be inserted into the table individually, append them to the table and finally write the table into the container.

DATA <ObjectList> TYPE SWC_OBJECT OCCURS 0.
DATA <Object> TYPE SWC_OBJECT.
SWC_CREATE_OBJECT <Object> <ObjectType> <ObjectKey>.
APPEND <Object> TO <ObjectList>.
...
SWC_SET_TABLE <Container> <ContainerElement> <ObjectList>.

For further information, refer to Writing a Multiline Object Reference into a Container.

Reading a multiline object reference

You declare a multiline object reference and fill it from the container.

DATA <ObjectList> TYPE SWC_OBJECT OCCURS 0.
SWC_GET_TABLE <Container> <ContainerElement> <ObjectList>.

For further information, refer to Reading a Multiline Object Reference from a Container.