Start of Content Area

Procedure documentation Correlation: Defining Assignment of Msgs to Process Instances   Locate the document in its SAP Library structure

Use

You use a correlation to assign messages that belong together to the same process instance. An integration process is to process a purchase order and the corresponding sales order, for example. The purchase order and the sales order have the same purchase order number. To ensure that the purchase order and the corresponding sales order are processed by the same process instance, you define a correlation using the purchase order number. The following example illustrates this:

Example

In a process, receivestep_1 receives the message purchaseorder, while receivestep_2 receives the message salesorder.

Receivestep_1creates a correlation that defines that the corresponding sales order must have the same purchase order number. Receivestep_2 uses this correlation.

This ensures that the purchase order and the corresponding sales order are processed by the same process instance.

Correlation

A correlation joins messages that have the same value for one or more XML elements. A correlation is therefore a loose coupling of messages: at design time, it enables you to define which message a receive step must wait for, without you having to know the message ID.

If it satisfies the relevant correlations, a message can be processed by multiple processes. However, each message is only delivered once per process.

Defining a Correlation

In a correlation you define the elements that the relevant messages are to be correlated with. For this purpose, you must define the elements in the correlation container. You then specify one or more messages that can satisfy the correlation at runtime. Finally, for each message, define which XML elements of the message payload will fill the elements in the correlation container.

The messages that can satisfy the correlation must give the values in the same format. If this is not the case, you must first perform a value mapping (more information: value mapping). The following example illustrates this:

Example

You want to define a correlation for Message_A and Message_B by using the purchase order date. Message_A from business system A gives the purchase order date in the format DD.MM.YYYY, while Message_B from business system B gives the purchase order date in the format YYYY.MM.DD. Before the messages can enter the integration process, you must define a value mapping that will create a uniform format for the date value for the purchase order date in both messages. 

Activating and Using Correlations

You can activate a correlation from either a receive step or a send step. To do so, specify the correlation you want to activate in the receive or send step and define how the correlation container is to be filled at runtime. The entire process container is available for this purpose. A unique key (GUID) is automatically created and persisted for the activated correlation.

You can use a correlation in a receive step. To do so, specify the correlation to be used in the receive step. At runtime, the correlation container is filled with the data from the message received, as is defined in the correlation. The system creates a correlation, compares it with the list of GUIDs and assigns the message to the process instance that has the same GUID. 

Within a loop, a correlation can be both created and used by the same receive step (more information: Example: Collecting and Bundling Messages from One Interface).

Validity of a Correlation

A correlation is normally valid within the whole process and can be activated and used for the whole process. However, you can also define a correlation as a local correlation by assigning it to a particular block. You can only activate and use a local correlation in the block that it is assigned to. You can, for example, use local correlations in blocks with dynamic processing to enable a separate value to be processed for the correlation for each block instance.

More information: Checklist: Making Correct Use of Correlations

Procedure

       1.      In the list of correlations in the object area of the process editor, enter the name of the correlation.

The name must be unique within the process.

More information: Process Editor

       2.      Choose This graphic is explained in the accompanying text with the quick info Details.

The correlation editor is displayed in the editing area.

       3.      Under Correlation Container, define the elements to be used to correlate the messages.

To define the correlation for the example above, create a container element for the purchase order number.

       4.      Under Involved Messages, select the messages that can satisfy the correlation at runtime.

To specify a message, choose the required service interface or the operation of the service interface.

More information: Service Interface

       5.      Specify for each message, which message element is to fill the corresponding element in the correlation container.

You can use context objects or XPath expressions for this purpose. 

 

End of Content Area