Technology Blog Posts by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
mohit_bansal3
SAP Mentor
SAP Mentor
2,982

Welcome to our Blog Series  on SAP BTP, where we delve into Build Process Automation for real-time business requirements and effortlessly handle complex scenarios using low-code and no-code development.

In this post, my colleague Adwait and I will delve into a complex solution that combines low-code and no-code techniques to streamline workflow design and approval with Auto Approval / Rejection Functionality.

Stay tuned for detailed insights, step-by-step instructions, and practical examples as we dive into the intricacies of SAP process automation. Whether you are a developer, business analyst, or SAP enthusiast, this series aims to empower you with the knowledge needed to optimize your processes.

Business Requirement: Problem Statement with Real world scenario :

mohit_bansal3_1-1718933173124.png

When dealing with intricate workflows, there is often a need for automatic approval or rejection based on specific conditions. Consider the following real-world  Budget Approval Workflow scenario:

Employee submits a budget approval form: An employee initiates a budget approval process by submitting a form. This form triggers a workflow that involves multiple steps.

Manager’s approval: The workflow routes the approval request to the employee’s manager. The manager receives the work item in their inbox.

Deadline considerations: If the manager fails to approve the request within a certain deadline, the workflow should automatically reject the request and mark it as completed.

Scalability & Reusable Approach

In this blog post, we will explore a highly scalable solution that can be adapted to various business requirements. Our focus is on automating approval processes when deadlines are missed. Here are the scenarios we have considered:

  1. Auto Approval: If a deadline is missed, we will automatically set a specific work item for approval.
  2. Auto Rejection: Similarly, if a deadline is missed, we will set a specific work item for rejection.
  3. Next Approval Level: When deadlines are not met, we will handle work items for the next approval level.
  4. Extending the Approach: We will also discuss how to implement similar steps for subsequent approval levels.

Technical Implementation:

We can understand the complete development flow with the step-by-step instructions.

mohit_bansal3_2-1718933349968.png

Step 1 & 2 : SAP BTP BPA Setup  In the SAP BPA setup, we have two key steps. First, ensure that the SPA BTP SAP Build Process service instance and service key are available. Assuming this is already in place, move on to the next step: make sure the SAP BPA Destination is also set up. Below, you’ll find a sample diagram illustrating the SAP BPA Destination, which will be used later to trigger the SAP BPA API for task retrieval and task completion.

Step 3 & 4 : API Identification from SAP API Hub aka Business Accelerator , Before delving into the solution, let’s closely examine the SAP Build Process Automation API. Together, we’ll explore how this API facilitates Workflow Tasks and Task Completion. Additionally, we’ll learn how to use it to post SAP Build process automation tasks:

  1. Querying Tasks in ‘READY’ Status (step 3): In the SAP API hub (specifically the SAP Business Accelerator Hub), you’ll discover an API that allows retrieval of user task instances based on specific parameters."
  1. Post the SAP Build process automation task task with READY Status via  via API (Step 4).

Querying the SAP Build Process Automations Tasks which are in “READY” Status.

In the SAP API hub, specifically the SAP Business Accelerator Hub, you’ll find the API that allows us to retrieve user task instances based on specific parameters. To get started, follow these steps:

  1. Navigate to the Monitoring Tab: Within your SAP environment, go to the monitoring tab.
  2. Identify the Workflow Instance: Find the specific workflow instance you’re interested in. Note down the process ID; this serves as the Workflow instance ID.
  3. Filter by Status: Filter the tasks by the status ‘READY.’ This indicates that the task is ready for processing.

Important Attributes

Values

Client ID

<<Value of client id from SAP BPA Service key>> 

Client Secret

<<Value of client secret from SAP BPA Service key>>

URL

https://spa-api-gateway-bpi-eu-prod.cfapps.eu10.hana.ondemand.com/public/workflow/rest/v1/task-insta...

OAuth Token URL

https://<<YOUR Domain>>.authentication.eu10.hana.ondemand.com/oauth/token

let's understand the above flow in a glance:

Patch the Task via API: sample Payload for the Patch API which will be used to update task

 

 

 

{
    "subject": "Patch API Sample",
     "status": "COMPLETED",
     "decision" :"approve"   
}

 

 

 

Step 5 & 6:  SAP Build Process Automation based Actions Project with API from Step 3 & 4

Implementation of the SAP Build Process Automation Based Actions Project. We have created a Action project named Auto approval action and selected the Api for the Querying tasks and update the tasks by ID. We have shown above how we will pass the parameters in sequence.

Below diagram will help you to create the action project step by step instructions.

mohit_bansal3_5-1718934184554.png

Step 7 & 8 : Approval Step in workflow: For demonstration purposes, we’ve set up a straightforward approval step that automatically approves tasks if they remain incomplete for one day.

The following sequence outlines the critical steps for this blog Below sequence of steps are the most critical steps for this blog.

Main Process Design implementing dead line monitoring 

mohit_bansal3_6-1718934245351.png

  1. Add the Timer Event
    • This step involves setting up a timer event in your workflow. The timer will wait for 1 day before proceeding to the next step. During this time, the work item will remain in a pending state.
    • Explanation: When a work item enters this stage, the timer starts counting down. After 1 day, it triggers the next action.
  2. Add the Sub Workflow Step:
    • Right after the timer event, insert a sub workflow step. This is where you can define additional actions or processes related to the work item.
    • Explanation: The sub workflow allows you to perform specific tasks or checks before moving forward. It acts as an intermediary step between the timer event and the auto approval process.
  3. Process the Auto Approval:
    • In the sub workflow step, implement the auto approval logic. This could involve checking certain conditions (e.g., work item type, requester, or other relevant data) to determine if the item can be automatically approved.
    • Explanation: If the conditions are met, the work item will be approved automatically without manual intervention. Otherwise, it will follow a different path based on your workflow design.

Remember to configure the details of each step according to your specific workflow requirements. Feel free to customize the timer duration, approval criteria, and any other relevant settings.

Sub Workflow Design: most important part of the blog

mohit_bansal3_8-1718934505833.png

  1. Create an Input Variable for Retrieving the Parent Process ID:
    • Begin by defining an input variable in your workflow. This variable will store the parent process ID.
    • Explanation: The parent process ID is essential for tracking the relationship between sub-processes and their main process.
  2. Map the Input Variable from the Main Process:
    • In your main process, ensure that you map the input variable (containing the parent process ID) to the appropriate value.
    • Explanation: By mapping the variable, you establish a connection between the main process and any sub-processes that rely on this information.
    •  
  3. Create an automation Step-in your main process, This help to set the "READY" "approve" and "COMPELTED"  flag which will be used in the action task later.mohit_bansal3_0-1718938667834.png

     

  4.  Configure the Sub Process Action Task:mohit_bansal3_9-1718935207394.png
    • Use the get task instances  API ( explained in the step 3 & 4) to retrieve relevant information related to the process ID. Within the sub process, add an action task. This task will query the task API using the provided “Process ID” and specific parameters.
    • Implement Auto Approval Logic in the Sub Process: Call the Task Completion API and Auto Approve the Task 😊 😊

mohit_bansal3_12-1718935339764.pngRemember to adapt  any additional settings / API / Logic  as needed.

Wow, We Are Done with Auto Approval! 😊

For testing purposes, feel free to set the wait time as short as 1 minute.

This approach can be scaled for auto approval, rejection, or escalation to the next level.

Conclusion Remarks: I hope you enjoyed this blog. The techniques discussed here can be applied to various scenarios, enhancing efficiency, and streamlining processes. For more insights into handling further complexity, stay tuned for our next blog by my colleague, Adwait.

Thank you for reading, and happy automating! 

Please feel free to get in touch with me over Linkedin.

Regards, 

Mohit Bansal ,

SAP BTP Platform Advisory & Solution Architect

4 Comments
Labels in this area