Procedure documentationWriting a Field Value into a Container Locate this document in the navigation structure

Prerequisites

The following prerequisites must be fulfilled in order to write a field value into a container:

  • The container must have been created and initialized.

  • For function modules, the include file <CNTN01> must be incorporated in the program. For ABAP classes, the include files <CNTN02> and <CNTN03> must be incorporated. For more information, see Macro Instructions for Processing a Container.

    Note Note

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

    End of the note.

Procedure

  1. Create a variable for the field value. Specify a database field as reference.

    Caution Caution

    If the container is used in a workflow binding, you must ensure that the field value has the same data type reference as the container element defined in the container definition.

    End of the caution.
  2. Assign a value to the variable.

  3. Write the field value into the container using the following macro instruction:

    SWC_SET_ELEMENT <Container> <ContainerElement> <Value>.

    Caution 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.

    End of the caution.

Result

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.

Example

This example is part of the implementation program for object type BUS1001.

Syntax Syntax

  1. * Typdeklarationen
    DATA:
    ENDLEADTME LIKE BAPICM61M-WZTER.
End of the code.

A value is assigned to the field ENDLEADTME when a function is called. The value in the field ENDLEADTME is written with the container element ID Endleadtme into the container CONTAINER.

Syntax Syntax

  1. SWC_SET_ELEMENT CONTAINER 'Endleadtme' ENDLEADTME.
End of the code.