Triggering SAP Build Process Automation Workflow from a Custom SAP Fiori Application

Triggering SAP Build Process Automation Workflow from a Custom SAP Fiori Application

In this blog, we’ll explore h to integrate SAP Build Process Automation with a custom SAP Fiori application. This involves creating a workflow in SAP Build Process Automation, setting up an API trigger, and calling this workflow from a Fiori application.

Steps to Trigger the Workflow

  1. Log in to SAP Build Process Automation

Navigate to the SAP Build Process Automation application.

 

santohrao_gundelli_28-1731967018055.png

 

  1. Click on “Create” button to create a New Business Process.

santohrao_gundelli_29-1731967030363.png

Select Business Process

santohrao_gundelli_30-1731967049053.png

  • In the Create a Business Process Project dialog box, do the following:
  • Enter a Project Name: Sales Orders Management
  • Enter a Short Description: Sales Orders Management Project
  • Choose Create
  • santohrao_gundelli_31-1731967078561.png

     

  1. Create your process

santohrao_gundelli_32-1731967095234.png

 

  1. Open the process and create a API trigger
     

    santohrao_gundelli_33-1731967132586.png

  2. Click on add API Trigger

 

santohrao_gundelli_34-1731967155051.png

  1. Once API trigger is created save the process and release and deploy.
 

santohrao_gundelli_35-1731967174795.png

 

  1. After creating API Trigger, we can see this trigger in Control Tower and we can trigger this Process from any SAP Fiori Custom application.
 

santohrao_gundelli_36-1731967190851.png

santohrao_gundelli_38-1731967394382.png

  1. Copy the URL, payload and we can trigger the process from postman or any custom UI5 application

 https://spa-api-gateway-bpi-us-prod.cfapps.us10.hana.ondemand.com/workflow/rest/v1/workflow-instances

 

Payload: {

    “definitionId”: “us10.cpi-workzone-dev-z49850t9.customfioriapproval.customApprovalProcess”,

    “context”: {}

}

santohrao_gundelli_39-1731967477114.png

7.Creating a Data Type and adding this data type to our trigger.

santohrao_gundelli_40-1731967561427.png

 

  1. Add a Field vendorNumber type string.
 

santohrao_gundelli_41-1731967614079.png

santohrao_gundelli_42-1731967635820.pngsantohrao_gundelli_43-1731967669998.png

  1. Add Data Type to trigger Process Inputs and Process Outputs
     

    santohrao_gundelli_44-1731967713049.png

     

Click on configure button and add input.

 

santohrao_gundelli_45-1731967744301.png

 

santohrao_gundelli_46-1731967770602.png

Similarly add process output

santohrao_gundelli_47-1731967827543.pngsantohrao_gundelli_48-1731967849858.png

 

Save, Release and Deploy

Now our api trigger is updated with process input variable and we can trigger the API from any UI5 application.

santohrao_gundelli_49-1731967899880.png

To trigger SAP Build Process API, you need a destination to be created in BTP cockpit.

Create an instance of SAP BUILD PROCESS AUTOMATION

santohrao_gundelli_51-1731967959110.png        

 

Create a service key

santohrao_gundelli_52-1731968004960.pngsantohrao_gundelli_53-1731968024369.png

Create a service key

santohrao_gundelli_54-1731968109761.png

 

Create Destination using client Id and clientsecret

 

santohrao_gundelli_55-1731968142014.pngsantohrao_gundelli_56-1731968161423.png

 

Code to trigger Build Process Automation from UI5 application, in controller add the below method

 _workFlowCall: function (oData) {

                var url = “/spa_process_destination/v1/workflow-instances”;

                var sUrl = this._getExternalServiceRuntimeBaseURL() + url;

                var payload = {

    “definitionId”: “us10.cpi-workzone-dev-z49850t9.customfioriapproval.customApprovalProcess”,

    “context”: {

        “vendordetails”: {

            “vendorNumber”: “”

        }

    }

}

                $.ajax({

                    url: sUrl,

                    type: “POST”,

                    dataType: “json”,

                    contentType: “application/json”,

                    data: JSON.stringify(payload),

                    beforeSend: function (xhr) {

                        xhr.setRequestHeader(“Accept”, “application/json”);

                    },

                    success: function (response) {

                        console.log(“Success: “, response);

 

                    }.bind(this),

                    error: function (error) {

                        console.log(“Error in POST call:”, error);

 

                    }

                });

            },

            _getExternalServiceRuntimeBaseURL: function () {

 var oComponent = sap.ui.core.Component.getOwnerComponentFor(this.getView());

                if (oComponent) {

                    var sAppId = oComponent.getManifestEntry(“/sap.app/id”);

                    var sAppPath = sAppId.replaceAll(“.”, “/”);

                    var sAppModulePath = jQuery.sap.getModulePath(sAppPath);

                    return sAppModulePath;

                } else {

                    console.error(“Component could not be found.”);

                    return “”;

                }

            },

 

Key Points

  • Ensure the destination is correctly configured in SAP BTP Cockpit for seamless communication.
  • Customize the context field in the payload to include relevant inputs required for your workflow.

By following these steps, you can successfully trigger SAP Build Process Automation workflows directly from a custom SAP Fiori application, enhancing automation and integration capabilities.

 

 

 

 

Scroll to Top