Example Procedure for Acting on Repeating Elements in Data

The procedure in this topic is an example of how to set up an expression that allows a business process to perform a specific action for each item in a list.

For example, when an order is processed to perform a specific action for the type of product purchased in the order, you must create a complex activity that can be used to iterate through x number of items. You would create a loop in the business process that performs an action for each item in a list of repeating items and terminates when the count exceeds the number of items in the data.

To set up looping:


  1. Create a business process service that uses data with repeating nodes.

    An example of this is an order item that contains details about the item, such as, its ID, name, color, and price.

  2. In your business process, select the Business Process tab.
  3. Click in the Business Process canvas to activate the Tool Palette.
    Note: If the Tool Palette does not appear either on the Fast View shortcut bar or as an open view in the perspective, open the Tool Palette.
  4. From the Activities tool palette, select the Complex activity and drag and drop it onto the canvas.

    In the following steps, we will define Complex activity that loops to check each item and do some type of activity. An example of this is, if the item color is blue, you could have an e-mail sent to marketing so they know this color is selling.

  5. Expand the Business Process Variables section.
  6. Select Local Variables, right-click, and select New Variable.
  7. Expand Properties.
  8. Select the default name and, for this example, type loopcounter in the Name field.

    The variable must be an integer, which is the default.

  9. Create a second local variable and type countnodes in the Name field.
  10. From the Activities tool palette, select the Assign activity and drag and drop it onto the canvas before the Complex activity.
  11. From the Properties Panel view, drag the nodes to be counted and drop it into the Source cell of the Assign.
  12. Drag the countnodes variable and drop it into the Target cell of the Assign.
  13. Select the Assign tab and click on the canvas.
  14. From the Node Set Functions tool palette, select Count and drag and drop it onto the canvas.
  15. From the Number Functions tool palette, select Round and drag and drop it onto the canvas.
  16. Connect the activities:
    1. Connect the repeating node to Count.
    2. Connect Count to Round.
    3. Connect Round to the target.
  17. Select File > Save from the main menu bar.
  18. Select the Complex activity to display its properties and in Properties, do the following:
    1. Select the Iteration Settings tab.
    2. Select This activity runs iteratively.
    3. Click the ellipse in the Counter variable field and select the local variable that you defined, loopcounter , as the X for the number of elements.
    4. Click the ellipse in the Counter initial field, select Literal, enter 1 , and click OK.
    5. Click the ellipse in the Counter increment field, select Literal, enter 1 , and click OK.
  19. Drag loopcounter onto the Xpath editor.
  20. Position the cursor at the end of loopcounter, right-click, and select Operators > <.
  21. Position the cursor at the end of < and drag countnodes onto the XPath editor.

To set up iterating over instances:

In the following steps, you will finish defining the Complex activity that you created above.


  1. Click on the Business Process editor canvas to activate the Tool Palette.
  2. From the Activities tool palette, drag Assign and drop it into the looping Complex activity.
  3. From the Business Process Variables section, drag the repeating element that contains the data you want to use and drop it into the Source cell of the Assign.
  4. Drag the parameter you want to send the data to and drop it into the Target cell of the Assign.
  5. Click the Assign tab.
  6. Select the source parameter.
  7. Find the repeating node in the XPath, put the cursor after this node, type [/loopcounter] and click OK.

    This assigns the data to the target for further processing.

Related tasks
Building a Complex Activity
Creating a Loop
Defining Business Process Variables
Defining Business Process Correlation Sets

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.