Quite
often there is requirement of implementing loops in a process. For example, you
may need to loop through an array of items ordered to fulfill each order items
in a OrderFulfilment process. Another example could be, loop through line items
in excel spreadsheet and process each line items individually.
The
loops are implemented using subprocess (adhoc loop in a process can be
implemented using gateways).
Oracle
BPM supports five loop characteristics in subprocess –
·
Single Instance Loop (simply called Loop)
·
MultiInstance Sequential Cardinal Loop
·
MultiInstance Sequential Collection Loop
·
MultiInstance Parallel Cardinal Loop
·
MultiInstance Parallel Collection Loop
To showcase the usages of each loop characteristics of
subprocess, let us define a process, as follows -
Single Instance Loop –
In the subprocess Loop characteristics setting, we will
select “Loop” and specify the loop condition as the loop count. In our example
to loop through the array, we specify the count of elements in the array through
an xpath expression.
Considering we have process data "order" of type OrderBO defined, to exact the individual item form the array, we use the predefined subprocess variable - "loopCounter" as follows -
To test the process, if we initiate the process with ItemA and ItemB in the array, it will create two Subprocess instances sequentially.
MultiInstance Sequential Cardinal Loop
This type of loop characteristics is very similar to "Simply Loop" discussed above, with additional feature to break the loop conditionally.
As you can notice the Cardinality (number of iterations in the loop) is specified as count of items array in the OrderBO. Similar to "Simply Loop", the corresponding item in the loop iteration can be retrieved using loopCounter subprocess predefined variable, as shown in the picture below -
MultiInstance Sequential Collection Loop
MultiInstance Loop with Creation Type "Collection" allow to implement loop characteristics through array iteration. A loop input and output data element is defined through expression which should be an array. For our example, order.items represents array of string, thus used in the loop input/output as follows -
"inputDataItem" predefined variable represent the element of the array corresponding to each iteration in the loop. Similar to MultiInstance Sequential Cardinal
MultiInstance Parallel
Cardinal Loop and MultiInstance Parallel Collection Loop are
very similar to MultiInstance Sequential loops, with the only
behavioral exception that all the instances of the array are created in parallel.
No comments:
Post a Comment