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.
Note
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 ensure that the element names and the data types that you use are in accordance with the definition.
A container element ID is always managed internally in upper case. 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>.
Note
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 . Include the include file <CNTN03> by choosing .
The container must be declared and initialized with the following macro instructions:
Syntax
SWC_CONTAINER <Container>. "Deklaration SWC_CREATE_CONTAINER <Container>. "Initialisierung
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.
Example
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.
Example
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.
Syntax
SWC_DELETE_ELEMENT <Container> <Containerelement>.
Note
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.
Syntax
SWC_COPY_ELEMENT <Quellcontainer> <Quellelement> <Zielcontainer> <Zielelement>.
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>.
Note
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.
Use the macros below to read multiline structures or multiline variables from a container or to write them into a container.
Syntax
SWC_SET_TABLE <Container> <Containerelement> <Wert>.
For more information, see Writing a Table into a Container.
Syntax
SWC_GET_TABLE <Container> <Containerelement> <TabellenVariable>.
Note
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.
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.
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 more information, see 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.
Syntax
DATA <Objekt> TYPE SWC_OBJECT. SWC_GET_ELEMENT <Container> <Containerelement> <Objekt>. SWC_GET_OBJECT_KEY <Objekt> <Objektschlüssel>. SWC_GET_OBJECT_TYPE <Objekt> <Objekttyp>.
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.
Syntax
DATA <Objektliste> TYPE SWC_OBJECT OCCURS 0. DATA <Objekt> TYPE SWC_OBJECT. SWC_CREATE_OBJECT <Objekt> <Objekttyp> <Objektschlüssel>. APPEND <Objekt> TO <Objektliste>. ... SWC_SET_TABLE <Container> <Containerelement> <Objektliste>.
For more information, see Writing a Multiline Object Reference into a Container.
You declare a multiline object reference and fill it from the container.
Syntax
DATA <Objektliste> TYPE SWC_OBJECT OCCURS 0. SWC_GET_TABLE <Container> <Containerelement> <Objektliste>.
For more information, see Reading a Multiline Object Reference from a Container.