Macro
Instructions for Processing a Container
You can use these macro instructions for the following programs:
· Implementation programs of classic object types (BOR objects)
· Function modules for event creation
· Function modules for rule resolution
· ABAP classes (for example, for use in programmer exits)
Processing a container instance includes:
· Accessing the value of a container element
· Entering a value for a container element
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 the values are in accordance with the container definition. You must make sure yourself that the element IDs and the data types that you use agree 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.
The include file <CNTN01> must have been included into the program to use these macros in function modules and in the implementation program. Use the following command 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.
To use the macros in ABAP classes, the include files <CNTN02> and <CNTN03> must be included. In the Class Builder, include the include file <CNTN02> by choosing Goto → Class Local Types → Macros. Include the include file <CNTN03> by choosing Goto → Class Local Types → Local Class Definitions/Types.
The container must be declared and initialized with the following macro instructions:
SWC_CONTAINER
<Container>. "Declaration
SWC_CREATE_CONTAINER
<Container>. "Initialization
For more information, see Declaration and Initialization of a Data Structure of a Container.
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 rule 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 responsible agent(s) carried out.
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.
SWC_DELETE_ELEMENT <Container> <ContainerElement>.

If the container element does not exist in the container, the error code 1is returned with SY-SUBRC, otherwise SY-SUBRC has the value 0.
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.
Use the macros below to read structures or single variables from a container or to write them into a container.
SWC_SET_ELEMENT <Container> <ContainerElement> <Value>.
For more information, see Writing a Field Value into a Container.
SWC_GET_ELEMENT <Container> <ContainerElement> <FieldVariable>.

If the container element does not exist in the container, the error code 1is returned with SY-SUBRC, otherwise SY-SUBRC has the value 0.
Use the macros below to read multiline structures or multiline variables from a container or to write them into a container.
SWC_SET_TABLE <Container> <ContainerElement> <Value>.
For more information, see Writing a Table into a Container.
SWC_GET_TABLE <Container> <ContainerElement> <TableVariable>.

If the container element does not exist in the container, the error code 1is returned with SY-SUBRC, otherwise SY-SUBRC has the value 0.
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:
· Checks whether the associated object type is defined and activated in the Business Object Repository.
· Sets an indicator in the container denoting that the entry is 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 more information, see Writing an Object Reference into a Container.
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 more information, see Reading an Object Reference from a Container.
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:
· Checks whether the associated object type is defined and activated in the Business Object Repository.
· Sets an indicator in the container denoting that the entry is an 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 more information, see Writing a Multiline Object Reference into a Container.
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 more information, see Reading a Multiline Object Reference from a Container.