Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
mohit_bansal3
SAP Mentor
SAP Mentor
3,690

Welcome back to our new blog series,  our previous blog series  delved into the intricacies of dynamic sequential approval workflows.

In this two-part series, my colleague @Adwait_Fadnavis  and I will explore some very critical business workflow  requirements  in detail using SAP Build Process Automation. 

Throughout this blog series, we will delve into the following critical business requirements:

Part 1 - Current Blog :Mastering Complex SBPA Approvals : A Deep Dive into Wait Steps, Script Tasks, and API Integrations

Part 2 : Demonstration with Complete end to end testing 

We will demonstrate how to use various SAP Build Process Automation tools to solve real-time challenges effectively.

This blog post addresses this complex requirement with detailed step-by-step instructions. You'll learn how to ensure workflows advance smoothly, even with  approval condition utilizing various innovative latest features such as: Wait Step with API Triggering , Workflow Context update via API etc.

Business Context and Problem Statement

While working on multiple SAP Build Process Automation projects, we have faced situations where workflows only proceed if all departments or approvers approve them unanimously.

If any approver rejects the proposal, the entire workflow is rejected . This creates a need for a parallel approval process, adhering to an "all-or-nothing" requirement, which SAP's standard solutions do not support.

In a below sample procurement workflow, the request is created and submitted. Both the Department Manager and Finance Department must approve it simultaneously. If either rejects, the workflow is terminated.

If both approve, the request goes to the Executive for final approval. The Executive's decision determines whether the request is processed or terminated.

Dynamic Number of Parallel ApprovalDynamic Number of Parallel Approval
Technical Solutioning & Design

In this process, we will create two workflows using SAP Build Process Automation’s Low Code/No Code approach.

Let’s refer to these as Workflow A (main workflow) and Workflow B.

mohit_bansal3_1-1748314489855.png

Workflow A( Main Workflow): This is the main workflow, triggered with all input parameters, responsible for the overall business process flow.

Workflow B(Secondary Workflow): This workflow handles the approval task. It receives the Approval ID, total number of levels, and current level. If the final approval is granted, it triggers a wait step API  in Workflow A to proceed to the next level. If more approvals are needed, it sends the Approval ID to the next level.

 
Technical Design Steps for Workflow A:
 
mohit_bansal3_0-1748320427762.png
  1. Trigger Workflow: The workflow is initiated with input parameters.
  2. Decision Creation: A decision step is created to determine the number of approvals require. mohit_bansal3_1-1748397456117.png

3. Script Task: This step determines the total number of approvals and the current approval level.

$.context.custom.doneapprovalcount = 0;
$.context.custom.currentcount = 0;
$.context.custom.subwfdefinationid = "Your Secondaray Workflow ID"; // replace with your secondary workflow id
$.context.custom.totalapprovalcount = $.context.decision_getAppprovers_1.Approvers.length;
$.context.custom.triggeredsubprocessids = [];
​
  • Condition Check: If the current level matches the total required approvals, A wait step will be created to wait for the completion. If not, Workflow B is triggered to initiate the approval task.

mohit_bansal3_0-1748402197865.png

  • Trigger Workflow B: Workflow B sends the work item to the respective user for approval.
  • Wait Step API : This critical step waits for all parallel approvals to be completed. Once done, the dummy decision is triggered by Workflow B. This is very interesting and latest features
    1. Create a Wait Step with API as follows. After Deployment it will event will create the API End Point which will used to trigger from secondary workflow B .      mohit_bansal3_2-1748398144169.png
    2. Execution ID is the Parent Workflow ID.
    3. Upload the API specification and create the action for this
    4.  Also make sure to create the API key which will be used to trigger it from secondary workflow B.
      mohit_bansal3_0-1748399148921.png

Technical Design Steps for Workflow B  (Triggered via Workflow A)

mohit_bansal3_0-1748326920552.png

  1. Trigger from Workflow A : Workflow B starts when Workflow A reaches a certain point to manage approval tasks separately and in parallel to the main workflow.

  2. Send Approval Task: The approval task is sent to the current level approver to obtain necessary approvals at each level before proceeding.
  3. On Approval: The system retrieves instance details and updates the approval count to keep track of completed approvals and update the workflow status.  mohit_bansal3_0-1748400024579.png
  4. sample code
$.context.custom.approvedcount = $.context.action_get_getV1WorkflowInstancesWorkflowInstanceIdContext_6.result.custom.doneapprovalcount + 1;
  • Check Count: The system checks if all required approvals are obtained:
    • If all approvals are done, the workflow proceeds to the next step.
    • If not all approvals are done This ensures the workflow only proceeds once all approvals are obtained
    • mohit_bansal3_1-1748400188638.png
  •  Update Parent Workflow A Approval Action : increment the update count. created a custom action. If all the approvals not done, then update the approval count via custom action. (refer our previous blog how to create action for workflow API)   mohit_bansal3_2-1748400611380.png
  • Retrieve Task ID & Trigger Wait API trigger wait step ( API) in Workflow A to signal that the approval process is complete / Reject  and it can proceed.
    • Now come to most crucial part of the Development: Trigger the wait step via API
    • Created a custom action project  for the wait step api end point.
    • mohit_bansal3_0-1748401010931.pngHere is the Input mapping for the API call. Needs to provide the API Key and Parent ID.
    • It will trigger the wait step in workflow A to approve / move forward the workflow . mohit_bansal3_1-1748401110811.png
 
In the upcoming blog post - Demonstration with complete end to end testing  , @Adwait_Fadnavis  will delve into the complete end to end testing for these which is very critical to understand the whole development flow.
 
Stay tuned for a comprehensive guide that will enhance your understanding and streamline your Development  process.

Regards,

Mohit Bansal,

SAP Mentor. SAP BTP Solution Architect

2 Comments