Skip to Content
Author's profile photo Arijit Mukherjee

Collect or Aggregate messages based on counter using NWBPM step by step

We had several requirement where we needed to collect a certain number of messages using BPM. In ccBPM, we used achieve this using Loop step like below where we used to define a loop and a counter and once the counter reached to the end condition, the loop step was terminated.

pic1.JPG

So how to achieve the similar functionality using NWBPM.Below is the process view.

NWBPM.jpg

In my scenario, the input message looks like below.

pic1.JPG

The NWBPM is going to accept 5 message with same structure  and aggregate those in a single message.

I am not going into PO ESR ID design as that is pretty simple. We are just having one ICO to pass the message with above structure to BPM and another ICO to receive the aggregated message out of BPM and write that into a file.

I will describe the properties of the steps I created in BPM.

  • Data Objects:

Counter:

pic1.JPG

This is a simple data object of type Integer to count the number of message received by the process.Below is the properties.

pic1.JPG

Inbound:


pic1.JPG

pic1.JPG

This DO is created from the data type DT_SRC which is created automatically once we imported the related Service Interface from PO.This acts as a variable/container to hold the intermediate  messages within BPM process.

pic1.JPG

  • Start Step: This step is to receive the first File/Message and trigger the BPM process.Here we also initialize the message counter to 1.

pic1.JPG

pic1.JPG

pic1.JPG

pic1.JPG

In the output mapping properties, we have initialized the counter to one by defining below function and mapped the first input file/message to Inbound DO which was created earlier.

pic1.JPG

  • Uncontrolled Merge: This is just a dummy step to make/complete the loop as exclusive choice can not have 2 input.

pic1.JPG

  • Exclusive Choice(checkCount):Here we check whther the counter reached to 5 or not. If not then the process continues with Continue line, else process diverted to CountReached line.

pic1.JPG

pic1.JPG

Condition for CountReached line as below.

pic1.JPG

  • Intermediate Message(Await Next Message): If the count of number of messages is not reached to 5 then we await for next message to come in.

pic1.JPG

Here we need to use a trigger to receive the next messages.In my case I have used same trigger as the file structure of the source messages are same and coming from same service interface.

pic1.JPG

In the output mapping, we need to append the new messages to the existing message in the process.

pic1.JPG

pic1.JPG

Here also we need to set the correlation so that the next messages are correlated based on the company name on the incoming messages. So basically if the process is called by multiple instances then it will generate the aggregated output based on the same company name.

pic1.JPG

  • MappingStep(IncrementCounter):In this step we just increment the counter by 1.

pic1.JPG

pic1.JPG

Double clicking on the [-] sign of the mapping line of the Counter will show you the function.

pic1.JPG

  • Automated Activity(SendAggregatedMessages):Once the counter reached to 5, this step will be executed where we have just sent the aggregated output to PO.

pic1.JPG

pic1.JPG

pic1.JPG

  • End: This is used to terminating the process.

pic1.JPG

That is it!!

The output should look like below.

pic1.JPG

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Robert Warde
      Robert Warde

      Very interesting Arijit.

      Author's profile photo Rajesh PS
      Rajesh PS

       

      Arijit Mukherjee

      Your valuable thought son this please.

      https://answers.sap.com/questions/12907416/how-to-collect-and-group-records-by-loop-count-in.html