Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 6 Grouping Activities : Overview of Loops

Overview of Loops
Loops allow you to execute a series of activities more than once. You can iterate based on the items in an array stored in the process data, you can iterate while or until a given condition is true, or you can iterate if an error is encountered while processing. The following are the types of loops that are available:
Iterate and repeat until true loops allow you to accumulate the output of a single activity in the loop for each execution of the loop. This allows you to retrieve output from each execution of the activity in the loop. See Accumulate Output for more information about accumulating the output of each iteration of a loop.
Index Variable
The index variable holds the current number of times a loop has executed. The iteration count starts at one the first time the loop is executed, and the count increases by one for each iteration of the loop.
You can access this variable like any other process data by referencing it with a dollar sign ($) in front of it. For example, if the index variable is i, and you want to specify a condition that the loop should execute three times (for a repeat until true loop), the condition would be $i=3.
Accumulate Output
For iteration and repeat until true loops, you can accumulate the output of one of the activities in a group by checking the Accumulate Output field. If you check this field, you can select one of the activities in the group, and each time the loop is executed, the selected activity’s output is placed into a list. The list of accumulated output for that activity is stored in a variable whose name is specified in the Output Name field. After the loop exits, this variable can be accessed in the same way other process data can be accessed by other activities.
Because you can accumulate output from only one activity in a group, you should design your group so that only one activity in the group holds the data to accumulate for each iteration. For example, you may want to accumulate a list of customer names from repeated executions of a JDBC Database Query task, or you may wish to accumulate the sum of the amounts for line items in an order.
 
The output for the selected activity is accumulated each time the activity is executed. Therefore, if you choose to accumulate the output of the same activity used in the condition of a Repeat Until True loop, the activity is executed and the output is added to the list before the condition is checked. In this case, you may wish to use a Mapper activity in the loop to accumulate the output. The Mapper activity is placed after the activity used for the condition of the loop so that the loop exits before the value is accumulated. Alternatively, you can place a Mapper activity outside of the loop to strip out the unwanted value from the output list after the loop exits.

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved