Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
DG
Active Contributor
0 Kudos

A common BPM usage is to collect IDocs received from an SAP until it stops receiving more messages. It may sound easy to create such a process, but if you want to be sure you get all the messages you have to thing about your design.



One way to do this is to use a deadline branch within a loop. This could look like the following:


!https://weblogs.sdn.sap.com/weblogs/images/251687272/NewPicture.png|height=250|alt=image|width=577|s...!


Messages are collected the following way. The first message triggers the process. The message is then collected to the multi-line element in the container. Since the loop condition is always true (1=1), the process continues back to the receive step and waits for the next message. When it receives it, the message is appended and the process is repeated.



If the receive step is not performed within one minute in the collect block, the deadline branch fires the exception “END”. This exception is caught in the append_invoices process, which is an empty branch, leading the application to the mapping and send steps.



There can be a weakness with this type of process. A message arrives after 59.7 seconds in the collect block, it is received and we are at point A, when the deadline branch is triggered. The END exception is then thrown before the message has been collected in the container element. The result is therefore that the message has been received but is not used in the mapping. It can be quite difficult to find this missing message; you need to have other ways of detecting the problem.



The main problem is to figure out whether the last message has been added to the list. My solution is to use a multi mapping to test if the message is in the list already. Since all IDocs have a unique number, it’s possible to check if the message is in the list.



I created a multi mapping containing the single element and the multi-line IDoc. I mapped this to a message with only a single field called status:




The switch statement has the following properties:

In this branch is then a container element, which adds the last message to the multi line element.



Because of the long time it might take to perform the mapping, I created a block around my loop with the following parameters. The correlation should therefore not be active after the END exception has been thrown:

2 Comments