Macro Instructions for Processing a Container
Use
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.
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.
Prerequisites
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>.
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:
SWC_CONTAINER <Container>. "Deklaration
SWC_CREATE_CONTAINER <Container>. "Initialisierung
For more information, see 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.
Activities
Container element
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>.
Copying a container element
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.
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 more information, see Writing a Field Value into a Container.
Reading a field value
SWC_GET_ELEMENT <Container> <ContainerElement> <FieldVariable>.
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> <Wert>.
For more information, see Writing a Table into a Container.
Reading a multiline field value
SWC_GET_TABLE <Container> <Containerelement> <TabellenVariable>.
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:
-
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.
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.
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:
-
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 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 <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.
Reading a multiline object reference
You declare a multiline object reference and fill it from the container.
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.

