Previous Topic: Process Loops and IterationsNext Topic: Loop an Operator in a Process


System Variables for Looping

You can create custom loop variables and manage them yourself, or use the available system variables for loops included with this release of CA Process Automation.

For example, you could create logic to calculate the duration from the start time of the first iteration of a loop to the current time for each loop. You could even use pre and post execution code to set up input into a loop such as

Instead of creating and updating your own loop counter variables, you can take advantage of built-in loop variables. The Loop operator and any other operator with loop settings support the following dataset variables:

Use CurrentLoopIteration when you need a standard loop counter. The CurrentLoopIteration variable contains the value 0 during the first iteration of the loop and increments by 1 at the beginning or end of each additional iteration. For example, if the operator is configured to loop 3 times, at the end of execution of all iterations, CurrentLoopIteration is equal to 3. Specifically, it is 0 in the first iteration, 1 in the second iteration, 2 in the third iteration, and 3 in the last iteration. The last iteration is not executed because it violates the loop condition.

Use OverallLoopDuration when you need to loop for some fixed time duration; for example, to loop for a maximum of 5 minutes and then exit. This variable contains the number of seconds between the start of the first iteration of the loop and the end of the last iteration. OverallLoopDuration is updated at the beginning and end of every loop iteration. It includes any delay set between iterations of the loop.

Note: You cannot modify the CurrentLoopIteration and OverallLoopDuration system variables. Although they appear in the operator dataset, their values do not change unless they are looping (operator Repeat Count > 1).