When I was configuring my scenario, I came across this significant property of Block step in BPM. With the help of different modes in Block steps of BPM, we can make it work as a loop or even as branch. This blog is basically to explain this behavior of the block step.
In this scenario files are placed on ftp, they are then picked by the file adapter and are delivered to the BPE. In the BPM files are appended to a multiline container and after getting transformed to the target structure they are placed back on ftp.
Loop: – To collect files that are sent to XI.
Receive Step: – Abstract asynchronous interface to receive files.
Container1: – To set the loop variable and increment it.
Container2: – To append the received files to the multiline Element.
Transformation Step: – To map the source and target structure.
Block Step: – To accumulate various BPM steps.
Send Step: – Abstract asynchronous interface to send the file.
As the receive step is defined in a loop we need to use correlation.
Refer to this blog to define correlation.
The Block step has three modes: –
The default mode is set when you don’t want the block to behave as a loop or a branch.
ParForEach is used in case if messages are processed further in parallel processing braches.
ForEach is used if the messages are processed in a sequential manner.
A ParForEach is not a means of improving performance. A ParForEach will not result in a split into threads.
A ParForEach has a high resource consumption rate.
We will see how to set these modes.
The first thing is we need a multiline container element because when you set the Mode as ForEach or ParForEach it is mandatory to give a multiline Element. (This is not required in case of Default mode)
We define various container elements to serve different purpose.
First element (m_empdet_multi) is for the purpose of collecting the files hence it is Multiline.
Second element (p_empdet) is for the purpose of receiving and sending the file.
Third element (var) is to initialize and increment the loop hence its category is set to Simple type
Forth element (k_empdet) is local to the Block step and is used to set the current line of the Block.
Second, we need to populate the multiline container Element with the input data.
The second container Step in the BPM is used to collect the files.
In this set the Target as the multiline element.
Operation is set to Append.
And Expression is set to the single line element.
Note: – the interface type of both the Multiline and the single line element is same.
Third, we need to set the mode in the block step.
This is the property window for the Block step.
In case of ParforEach and ForEach we need to set the Multiline Element and Current Line.
In this case the Multiline Element is set to the Multiline element defined in the container window.
The current line is set to the element that is local to the block step.
Note: – the Interface type of the Multiline Element and the Current line is same.
We will see the Runtime behavior of the Block step.
Case 1: – Mode is set to Default.
In this case when we place the files on the ftp, file adapter picks them. As the loop variable is set to 3, three files are appended to the multiline Element. The files get transformed from the source to target structure. But as the Mode is set to Default only the last file is sent back to ftp.
We can check this behavior in SXI_MONITOR, where we can see that there are 3 input files but only one output file.
Case 2: – Mode is set to ForEach.
In this case when we place the files on ftp, file adapter picks them and again three files get appended to the multiline Element. The files are transformed to the target structure. Now as the Mode is set to ForEach, the Block acts as a loop and hence all the three files are placed on the ftp in a sequence
Goto SXI_MONITOR where we can see that there are 3 input files and 3 output files.
Click on PE to check the internal behavior of the Block step. Click on Goto and select List with technical details.
Expand the block step and we can see that the block has executed in form of a loop.
Case 3: – Mode is set to ParForEach.
In this case again we place the file, which gets picked by the adapter and is forwarded to the BPE. The files populate the multiline container. However, in this case the block acts as a Fork and hence the output files are placed on ftp in parallel.
We can check this behavior in SXI_MONITOR, where we can see that the block is executed in form of branches.