Vous êtes sur la page 1sur 10

Containers

There are 5 types of containers used in SAP Business Workflow. What is Container?

A container is a table like structure for collecting and storing data within the workflow and its components.

A container definition defines the structure of the data values to be stored in the container instance. A container definition is assigned to the following workflow components: Object Method Role Parameters Customer/Standard Tasks Workflow Definition

Container definitions are defined in the various workflow components by a container editor. A container instance is a runtime representation of a container definition. It refers to field values, multiline field values or object types. Application data is not stored directly in the container instances. The data utilized within a workflow is managed by the application and stored in the database. Data assignment to a container element is carried out by: Dataflow between container elements Assignment of values by an application program

A container definition consists of elements. Each container elements consists of the following: Element Name: A unique identification of the element Description: A short and detailed description of the element which is transferred to input screens and displays Data Type Reference: The ABAP/4 dictionary field or object that defines the structure of the data stored within the element Multiline Indicator: Indicates if the element is multiple lines (table) Import/Export Indicator: Indicates if the values of the element at runtime will be imported and/or exported Mandatory Indicator: Indicates whether the element must contain a value at runtime

Predefined container elements exist for system information of the workflow and components including: Workflow start time and date Workflow initiator

A container editor allows individual container elements to be created and edited. Functions available in the container editor include: Creating new container elements Editing container elements Changing views of the container elements Selecting container elements for deletion, copying, and cut and paste operations Sorting and filtering container elements

Element names must begin with a letter. The element name can be automatically assigned by the ABAP/4 Dictionary field name.

Data flows between the workflow components as follows: 1) Triggering event is created in application. 2) The workflow receives the application data from the event. 3) The workflow step transfers application data from the workflow to the synchronous customer/standard task. 4) The task transfers application data from the task to the object method parameters. 5) The execution of the object method may change the application data. The object method parameters transfer data to the task. 6) The task transfers application data back to the workflow. 7) The workflow step transfers application data from the workflow to the synchronous customer/standard task. 8) The workflow step transfers application data to the standard role parameters. 9) The task transfers application data from the task to the object method parameters. 10) The execution of the object method may change the application data. The object method parameters transfer data to the task. 11) The task transfers application data back to the workflow. 12) The workflow step transfers application data from the workflow to the asynchronous customer/standard task. 13) The task transfers application data from the task to the object method parameters. 14) The terminating event transfers application data to the task.

15) The task transfers application data back to the workflow.

The dataflow between the application and workflow container elements and between the elements of the workflow container, event containers, task containers, role containers, and method parameter containers is controlled by a set of rules called the binding definition. Binding definitions are developed using the binding editor and are optional for each container element. The binding editor is available when defining: Workflow definitions Triggering events Workflow steps Workflow steps with: Standard roles Object methods with parameters

The binding editor always references the container to receive the application data. Binding definitions can reference: Constants Variables (container elements) System fields

Containers hold values which are passed to other containers through binding during the runtime execution of workflows. It may be necessary to create new containers, new container elements, and change the values of container elements through ABAP/4 code. Editing container instances is necessary when: Creating object types or extending existing object types by adding attributes and methods Writing new function modules to create events Writing new function modules to perform dynamic role resolution

The container instance's values are edited using pre-defined macros containing ABAP/4 code. All the macro instructions required for editing container elements are contained in the include <CNTN01>. ABAP/4 function modules designed to create events or perform role resolution need to contain the include <CNTN01> in order to use the macro instructions. Object type implementation programs contain the include <OBJECT>. This include automatically incorporates the include <CNTN01>, so <CNTN01> does not need to be referenced again in the implementation program.

If you are creating function modules for event creation, you will need to create, initialize and release containers. In an object type implementation program, this is unnecessary. A container called CONTAINER is created automatically and the macros to manipulate the values of the container elements are at your disposal through the <OBJECT> include. The following macro instructions define and control containers: SWC_CONTAINER ContainerName: Declares a container called ContainerName. SWC_CREATE_CONTAINER ContainerName: Initialises the container called ContainerName. ContainerName must be previously declared. A container cannot be edited until it has been initialised. SWC_RELEASE_CONTAINER ContainerName: Releases the container called ContainerName. A container cannot be edited after it has been released.

Throughout the remainder of this chapter, assume that unless you are coding in an object implementation program, you will need to incorporate the includes <CNTN01> or <OBJECT> and use the appropriate macros to declare and initialize containers before using the other macros to write values to containers or read values from them.

The following macro instructions retrieve and set the values of container elements which are defined by fields : SWC_GET_ELEMENT ContainerName ElementName Variable: Retrieves the value from element ElementName in container ContainerName and places it in Variable. If the element does not exist in the container, SY-SUBRC will be set to 1; otherwise it will be 0. SWC_SET_ELEMENT ContainerName ElementName Variable: Assigns the value from Variable to the element ElementName in container ContainerName. If the element exists in the container, its value is overwritten; if it does not exist, its value is appended to the end of the container with this new value.

NOTE: ElementName must be typed in the macro instruction exactly as it is represented in the container definition, including lower and upper case letters. ElementName must be in single quotes. The following macro instructions retrieve and set the values of container elements which are defined by multiline list of values :

SWC_GET_TABLE ContainerName ElementName InternalTable: Retrieves the value of multiline element ElementName from container ContainerName and places it into the InternalTable. If the element does not exist in the container, SY-SUBRC will be set to 1; otherwise it will be 0. SWC_SET_TABLE ContainerName ElementName InternalTable: Assigns the InternalTable to the multiline element ElementName in container ContainerName. If the element exists in the container, its value is overwritten; if it does not exist, its value is appended to the end of the container with this new value.

SWC_DELETE_ELEMENT ContainerName ElementName: Deletes the value of the element ElementName in container ContainerName. If the element does not exist in the container, SYSUBRC will be set to 1; otherwise it will be 0. NOTE: ElementName must be typed in the macro instruction exactly as it is represented in the container definition, including lower and upper case letters.

To transfer the value of an object reference in your program to a container element defined to be the structure of an object type, several steps are necessary: Declare a variable for the key fields of your object : To declare a variable to hold the key field(s) of the object, use the data statement and declare the key field(s) to be like a type, field or structure from the ABAP/4 Dictionary. DATA KEY LIKE <structure/field/type>, or DATA: BEGIN OF KEY, KEY1 LIKE . . ., KEY2 LIKE . . ., END OF KEY.

Assign value(s) to your key fields using the usual ABAP syntax. Declare a variable as an object, use the following syntax: DATA ObjectVariable TYPE SWC_OBJECT.

To create an object instance in your program, use the following macro instruction: SWC_CREATE_OBJECT ObjectVariable ObjectType ObjectKey. ObjectType should be in single quotes.

Transfer the value of your object instance to the container element defined to be like an object with the following macro: SWC_SET_ELEMENT ContainerName ElementName ObjectVariable: Assigns the value from ObjectVariable to the element ElementName in container ContainerName.

To transfer the value of an object reference from the container to a variable defined in your program, several steps are necessary: Declare a variable for your object: DATA: ObjectVariable TYPE SWC_OBJECT. SWC_GET_ELEMENT ContainerName ElementName ObjectVariable. Read the value of the container element into your object: To obtain the key field values of this object, declare a variable to hold the key field(s) of the object. Check the object type key field definitions to make sure you declare your object variable key to be identical in structure. DATA Key LIKE <structure/field/type>, or DATA: BEGIN OF Key, Key1 like . . ., Key2 like . . ., END OF Key. SWC_GET_OBJECT_KEY ObjectVariable Key.

To obtain the key field(s) value(s), read the object type key into your key variable: To obtain the object type from the object variable, declare a variable to hold the type and then call the following macro:

DATA: OTypeVariable LIKE SWOTOBJID-OBJTYPE. SWC_GET_OBJECT_TYPE ObjectVariable OTypeVariable.

Example: data: reqite* declare internal table object, object work area and key structure of object ms type swc_object occurs 0. data: reqitem type swc_object. data: begin of preqkey, number like eban-banf, item like eban-bnfpo, end of preqkey. select purchase reqn. records from eban and fill the key fields defined above select * from eban. preqkey-number = eban-banf. preqkey-item = eban-bnfpo. create an object instance for each record drawn from eban append this object to the object internal table swc_create_object reqitem BUS2009 preqkey. append reqitem to reqitems. endselect. transfer the internal table entries out to the multiline container element. swc_set_table container PRItems reqitems.

To transfer the value of a multiline object reference from the container to the internal table object defined in your program, several steps are necessary: Read the value of the multiline object container element into your internal table object: SWC_GET_TABLE ContainerName ElementName TabObjects. DATA TabObject TYPE SWC_OBJECT. Declare a variable for your internal table object: Loop through the TabObjects internal table into TabObject, manipulating the individual lines as necessary. To obtain the key field(s) value(s), read the object type key into your key variable: Define the key field(s) of the object. DATA Key like <structure/field/type>, or DATA: BEGIN OF Key Key1 like . . ., Key2 like . . ., END OF Key.

SWC_GET_OBJECT_KEY TabObjects Key.

To obtain the object type from the multiline object, declare a variable to hold the type and then call the following macro: DATA: OTypeVariable LIKE SWOTOBJID-OBJTYPE. SWC_GET_OBJECT_TYPE TabObjects OTypeVariable

Vous aimerez peut-être aussi