Show TOC

Procedure documentationModeling Multi-Instance Loops of Activities Locate this document in the navigation structure

 

You use the Parallel For Each loop option in the process composer to model multiple parallel instances of activities in the process model. Thus, at runtime you can execute a dynamic number of activity instances in parallel. You define the exact number of instances to be executed at runtime with a loop context in the process composer. To define the loop context, you can select a specific data object with an XSD element, which is a list from the process context, or use an expression, which evaluates to a list. The number of elements in the list defines how many instances are executed.

All the instances of an activity are executed in parallel. The process flow continues after this activity when all of its parallel instances have been completed. You can use the Parallel For Each loop option and execute multiple instances of the following activities:

  • Referenced sub-process

  • Embedded sub-process

  • Automated activity

  • Human activity

  • Mapping activity

  • Reporting activity

When you use the Parallel For Each loop option, the following additional loop-specific data objects are automatically created:

  • numberOfCompletedIterations

    This data object contains the number of completed loop instances.

  • currentCollectionItem

    This data object contains the list element assigned to each loop instance.

These two data objects are only relevant for loops and are part of the local context of the activity for which you model the multi-instance loop. Thus, you can use the loop-specific data objects when you define input and output data mapping for this activity, but you cannot use the two loop-specific data objects for data mappings of other activities in the process.

You can use the loop-specific data objects only as a source when defining data mappings but not as a target. If it is necessary to transport information from within the loop context to a data object outside the loop context, you define the corresponding output mapping and append, for example, the loop mapping nodes to the existing ones in the data object. For more information about mappings, see Defining Data Mappings.

Prerequisites

  • You have opened the Process Development perspective in the SAP NetWeaver Developer Studio and have expanded your project in Project Explorer view.

  • You have created an activity of such a type which allows you to use the Parallel For Each loop option.

  • You have created the necessary data object containing a list to use it for a loop context. For more information about data objects, see Creating Data Objects and Process Context.

Procedure

  1. Expand Process Modeling, then expand Processes.

  2. In the context menu of a process, choose Open.

  3. In the modeling surface, choose an activity.

  4. On the Looping tab page in the Properties view, select the Parallel For Each radio button.

  5. Define the loop context using one of the following options:

    • Select the Select collection radio button and select a data object from the Collection dropdown menu.

    • Select the Use expression radio button and choose the Edit... pushbutton to specify an expression in the expression editor which evaluates to a list. For more information about expressions, see Creating Expressions.

      Choose the OK pushbutton.

Result

You have modeled a multi-instance loop of an activity. A parallel marker appears at the bottom center of the activity flow object in the process model. When the process flow reaches the activity at runtime, as many activity instances as you defined with the loop context are started in parallel.