EDUCAÇÃO E TECNOLOGIA

Execute workflow tasks in parallel using SAP Workflow Management


Overview

I have explained about  Referenced Sub flow in my previous blog. Now SAP Workflow Management has introduced some new powerful capabilities enable developers to execute activities in parallel. So far developers could model only static number of parallel branches in a workflow. Use cases requiring dynamic number of parallel activities of the same type is possible now in SAP Workflow.

Use cases

For eg: Multiple Line items in a Purchasing document require approval based on line items  with different approvers.

A document needs to be reviewed or approved by multiple users in parallel depending on the requestor choice.

An investment approval request sends to multiple approvers of the same level in parallel and each approver needs to make a decision.

All the above use cases require dynamic number of parallel activities and after completion of these activities the workflow needs to continue to execute the next set of activities. The new parallel for each feature enable customers to implement above use cases. The referenced subflow feature enable developers to assign a collection from workflow context and each element in the collection will be used to create a new workflow instance as a child workflow.

Parallel Workflows

In the below workflow model, there are two approval steps. A cost center owner approval and group head approval. There could be multiple cost center owners based on number of items in the request or the same request needs to be approved by multiple cost center owners in parallel. Each item may be charged to a different cost center and the corresponding cost center owner need to approve the requested item. The Cost Center Owner approval is modeled as a referenced subflow and marked for parallel execution. The parent workflow will wait until all the referenced subflow workflow instances complete execution and continue with the next activity, Group Head Approval.

The below configuration shows how to model a reference subflow executing multiple workflow instances in parallel during runtime. The property Type needs to set as parallel. A collection based on number of workflow  instances required to be assigned to the Collection Context Path. This collection can be dynamically built in the workflow context using a scrip task or pass through workflow start. Each element in the collection will have an equivalent workflow instance. The completion condition is an optional property explained later in this blog.

Conditional Exit in Parallel Workflows

When you execute workflows in parallel using a Referenced Subflow, the next activity will be started after completion of all the workflow instances started. But there could be conditional exits where the Referenced Subflow need to terminate some of the parallel running workflow instances. for eg: in the above example, one of the cost center owners reject the request, the approval request is no more valid.

Completion Condition

A completion condition can be defined based on the status of a context variable from the referenced subflow instances. This status variable can be mapped in the output mapping. In the below example a completion condition is defined. The loop.counter is a standard variable enable access to the output mapping from each of the referenced subflow instances.

${context.CCApprovers[loop.counter].decision== "reject"}

The referenced subflow out put mapping receives the status variable “decision” from each of the referenced subflow instances.

If one of the parallel running subflow instance has status reject, the referenced subflow will complete the execution and continue the next steps.

Monitoring

SAP Workflow Management offers out of the box monitoring capabilities to keep track of all workflow instances. It is possible to navigate between the main workflow and referenced workflow instances providing a parent child view. This enables developers or administrators to easily manage the workflow instances belongs to a specific parent workflow.

Summary

The new par-for-each feature in Workflow Management improve the process performance by executing workflows in parallel without any additional synchronization logic developed and easy to monitor these instances using Monitor workflow applications.

SAP Workflow Management has released Boundary Events to raise escalation events from a referenced subflow. Please go through my next blog about how to consume Boundary Events in a referenced subflow.