Skip to content

For Each

The For Each activity provides iteration and repetition. You can use the For Each activity to process contained activities a defined number of times (exactly N times where N = the final counter value minus the start counter value). The process iterations can occur in parallel or in sequence.

  • Parallel For Each--— In a parallel For Each, the instances of the enclosed activity must execute concurrently N times. Use a parallel For Each for simultaneous processing.
  • Sequential For Each--— In a sequential For Each, each instance of the enclosed activity executes sequentially. The first time the Scope activity executes the counter variable is initialized to the start counter value. The next iteration causes the counter variable to initialize to the start counter value plus one. Subsequent iterations increase the previously initialized counter variable value by one until the final interation where the final counter value is reached.

Things to know about For Each

  • You can use the For Each counter variable to access the current iteratin value.
  • When the For Each activity starts, the expressions in <startCounterValue> and <finalCounterValue> are evaluated.
  • The child activity of a For Each MUST be a Scope activity.
  • Make sure that the start and final value expressions evaluate to an xs:unsignedint. If they do not, a runtime exception will occur. The For Each won't execute if the final value is greater than the start value.
  • If the start counter value is greater than the final counter value, then the child Scope activity must not be performed and the For Each activity is complete.
  • The For Each activity completes when the current value is greater than the value of the Final Counter expression.

To build a For Each activity

  1. From the Control section of the palette, drag a For Each activity to the BPEL Editor.

  2. In the Properties view of the For Each, fill in the required properties:

  3. To create a For Each that executes in parallel, select Parallel Execution. If you do not select this option, the scope's activities will execute sequentially.
  4. Add a Counter Name that identifies the enclosed Scope's local variable.
  5. Start Counter Value. Add an unsigned integer for the value. Type in a value or select XPath Editor button to open the XPath Expression Editor.
  6. Final Counter Value. See the instructions above for Start Counter Value.

  7. Fill in the properties for the Scope container.

More information