You have the option of collecting multiple messages for an interface and bundling them into one message, for example, individual purchase order items into one purchase order. To do so, you need to define a receiver step within a loop. A loop can finish in a variety of ways.
The following table shows the various options. You can find the examples in the Enterprise Services Repository under SAP Basis → SAP Basis <release number>, namespace http://sap.com/xi/XI/System/Patterns.
Collect and Bundle |
Description |
Example |
Payload-Dependent |
The loop finishes when the number of messages received matches the number specified in the payload of the messages. |
BpmPatternCollectPayload |
Time-Dependent |
The loop finishes at a specified point in time. |
BpmPatternCollectTime |
Message-Dependent |
The loop finishes when a specific message is received. |
BpmPatternCollectMessage |
The example processes receive messages in a loop. The first message received starts the process and activates the correlation Correlation by using an ID. Each subsequent message uses this correlation. The messages are received in the container element CollectMessage. In the loop the received messages are attached to the multiline container element CollectMessageList. The following examples show the different options you have for defining the loop.
Once all the messages have been received, a transformation step bundles the messages collected in the container element CollectMessageList and from them creates a message in the container element NewMessage. This message is then sent by a subsequent send step.
The processes use one of the abstract interfaces as an inbound interface, and one as an outbound interface (see also: Process Signature).
Each message that is received in the loop contains a number in the payload, which corresponds to the total number of messages to be received. In the loop, a container operation counts the counter Counter for the number of messages received. The loop continues to run while the number of messages received is not equal to the number of messages to be received.
The following graphic illustrates the process definition:
The loop for receiving the messages is defined as an infinite loop. The infinite loop forms a branch within a block. A deadline has been defined for the block. When the deadline is reached, the process is diverted into the designated branch. A control step then triggers an exception in this branch. The relevant exception handler ends the block (normal completion, no error status).
The following graphic illustrates the process definition:
The loop for receiving the messages is defined as an infinite loop. The infinite loop forms a branch within a fork. A receive step is defined in a parallel branch to receive the message that ends the process. The fork is complete when both branches return true. However, since the infinite loop always returns true, the fork is only complete when the message that ends the process is received.
The following graphic illustrates the process definition:
Correlation: Defining Assignment of Messages to Process Instances