cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to trigger Build Process Automation (BPA) workflow through Business Application Studio?

0 Likes
4,994

Hi Team,

Greetings!

I have a requirement to trigger Build Process Automation from Custom UI5 application developed in BAS. I have gone through multiple tutorials but all are suggesting the triggering of BPA from Build Apps. 

Please guide me on this.

Thanks & Regards,

Ayushi Shrivastava

Accepted Solutions (1)

Accepted Solutions (1)

Dan_Wroblewski
Developer Advocate
Developer Advocate

I will see if I can find a better tutorial, but here is one that shows you how to do it the "old  way" (meaning making an API call) from SAP Build Apps, and it would work pretty much the same way for you.

  1. Create destination, as described here: https://developers.sap.com/tutorials/spa-create-service-instance-destination.html (this also may be created automatically for you when you install Process Automation)
  2. Make API call as described here: https://developers.sap.com/tutorials/build-apps-workflow-trigger.html#23115af3-8c2e-487a-b50a-ecdc7c... (step 5)
    • Call the POST API (2nd one on the page) as described in this API reference: https://api.sap.com/api/SPA_Workflow_Runtime/path/post_v1_workflow_instances
    • You need to send as header Content-Type as application/json, and in the payload you need to send as it shows in process automation for your process. To find payload, go to the SAP Build environment where you deployed the process, under Triggers find the trigger you created for your process, and select View (all the way to the right). Now you will see the payload you need to send. Dan_Wroblewski_0-1721115863892.png

I will try to find a tutorial showing it from JavaScript, for example, from BAS. But I think you'll get the idea from the above. 

0 Likes
Hi Daniel, thank you for sharing this , have started working on it. Please do share if you find any tutorials for BAS BPA integration. Just one question can we do this through ABAP RAP? In place of developing a capm app can we do it through abap rap application?
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes
In the end you are just calling an API so you could do it from anywhere you can make HTTP calls (helps to use destinations but not required).
VaradBhagwat
Explorer
0 Likes

Hi, I'm getting 401 unauthorized error while calling Build Workflow API trigger from my SAPUI5 application (both locally running or from Build workzone). The URL called is "https://spa-api-gateway-bpi-us-prod.cfapps.us10.hana.ondemand.com/workflow/rest/v1/workflow-instance..." to get X-CSRF token. My Workflow created as per tutorial https://developers.sap.com/tutorials/spa-academy-run-salesorderprocess.html#fb19e3da-bee0-4477-afc4-... Can you suggest what is the possible resolution for this issue.

What is the correct URL to trigger the BPA workflow API from the SAP UI5 app. And what is the correct method to call the API ?

1. Calling SBPA Workflow API to trigger process from SAPUI5 app

VaradBhagwat_0-1738033439576.png

2. 401 unauthorized error -

VaradBhagwat_1-1738032941489.png

3. CORS issue while testing UI5 app locally or from Build Workzone

VaradBhagwat_2-1738032941664.png

 

Answers (3)

Answers (3)

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes

It doesn't seem you are calling via the destination. My colleague @nicoschoenteich did a 2-minute series on UI5, including this video how he set up access to external API using destination via approuter and to test locally.

https://www.youtube.com/watch?v=MHJzIz7iiHs&list=PL6RpkC85SLQC4kuj22e4hw85Sa1pClD8y&index=4

Check out the entire series and subscribe to SAP Developers.

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes

@VaradBhagwat The second 2 screenshots are hard to read.

1) Where are you sending the credentials?

2) We usually solve CORS by creating a proxy service, or more simply using BTP destinations

VaradBhagwat
Explorer
0 Likes

I've set up the destinations and provided the service key etc. however, I'm still having doubt how to call the SBPA API from UI5 app and using the destinations to avoid CORS issue. Is the code snippet provided a correct method or there is another way to trigger API as per current technical design/architecture ? My overall BAS code structure modules is as follows - 1. A MTAR module project which has a a. Managed App router, b. Workflow Start UI module for approval view layout 2. A custom UI5 app which will trigger the BPA API (separate from above mentioned MTAR module project) 3. SBPA approval project (API trigger process as per template Sales Order Management MI04 as per the tutorial https://developers.sap.com/tutorials/spa-academy-salesorder.html ) 4. SAP Build Workzone tile to launch app and trigger process (UI5 app as in #2 above)

  1.  MTAR module project

VaradBhagwat_0-1738105971621.png

2. Error in console

VaradBhagwat_1-1738105971624.png

3. CORS error

VaradBhagwat_2-1738105971631.png

 

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes

I do not know if there is a special shortcut in SAP Business Application Studio as there is in SAP Build Apps, but you probably do this best by calling the SAP Build Process Automation APIS:

https://api.sap.com/package/SAPProcessAutomation/rest

The triggering API is under the Workflow tile. You need a service key and destination (generally created for you when you install Process Automation).

 

0 Likes

Hi Dan,

Thank you so much for promptly responding and providing the way out for my issue. It would be really appreciated if you can provide some reference tutorial or blog to implement this as i am quite a newbie in the area of Build Process Automation.

Thanks & Regards,

Ayushi Shrivastava