Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
MartyMcCormick
Product and Topic Expert
Product and Topic Expert
This is the second blog in a three part series demoing SAP Build Process Automation (SBPA) along with SAP Build app to call an API in SAP S/4HANA Cloud, public edition (S/4HC).  To recap, the app allows end users to enter basic information about a new project and submission triggers an approval workflow on SBPA.  After approval, a call to S/4HC is made to create the project with the data submitted and a default set of work packages.  In part 1 of this series, I covered how to create a REST API integration flow on BTP Cloud Integration to handle the API for SBPA and subsequent API mapping for S/4HC.  In this blog, I’ll cover the SBPA setup to handle the approval workflow and call to the REST API on BTP CI via an Action.

There are 3 main steps required for SBPA.

  1. Create BTP Destination for BTP CI REST Endpoint

  2. Create an Action to handle the API call to BTP CI.

  3. Create the Business Process to handle call from SAP Build app, approval workflow forms, and incorporate action call.


Note: There are also other blogs/tutorials that can be referenced for more information on adding actions to process automations including this one.

Create BTP Destination for SAP BTP Cloud Integration


A BTP destination is needed in order for SBPA to connect to our REST API.  An example outlining the process to create a destination is documented here.

The Client ID, Client Secret and Token Service URL are found in the service instance key of your BTP CI subaccount.

You can find the REST endpoint when you deploy your integration under the Operations View->Manage Integration Content.  You can remove the /clientproject from the end of the URL which then produces a value: https://<subaccount>-rt.cfapps.sap.hana.ondemand.com/http/

The following additional properties should be added to use the destination in SAP Build:

  • sap.processautomation.enabled = true

  • sap.applicationdevelopment.actions.enabled = true



BTP Destination for BTP Cloud Integration


 

Create Action for REST API


Note: an end to end tutorial for Action creation can be found here.

An OpenAPI Specification is needed in order to create the action based on the REST endpoint created in the first blog.  I created this file by using chatGPT to generate the specification based on the JSON payload that was used to build the iFlow.  To keep things simple, I used all String datatypes but if you wanted to perform validations you could correctly set the datatypes.


Using chatGPT to generate OpenAPI 3.0 file


 

Navigate to the SAP Business Process Automation app on BTP and select Build an Automated Process.


Build an Automated Process


 

Next click on Actions to create a new Actions project.


API Action


 

Give your project a name and description and provide the OpenAPI file created in the previous step.


Add the POST action


API Action


 

 

Next, you'll want to enable CSRF for the action via Settings in the upper left.

 


Enable CSRF for Action


You can modify any API fields that you need to in the Action or default fields.


Action API Fields


 

In order to verify that our Action works correctly, we can test it right from the project by clicking on Test and inputting some test data.  A successful test should result in a HTTP 201 response, which it does in this case.


Testing API in Action


 

Verifying that the call worked end to end, I can see the newly created project in S/4HC by querying the projects API in S/4HC directly from Postman.


Project in S/4HC


 

Once testing is complete, the Action can be released and published.


Release the Action


 


Publish the Action


 


Published Action


 

Create Business Process


The destination needs to be added to SBPA before creating the Business Process.  In the Build lobby, navigate to settings and you should see a popup to add the destination.


Adding Destination to Build


 

Now it's time to create the Business Process.


Business Process


 


Business Process Naming


 

After creating the new Business Process, create a new Data Type with fields matching the JSON payload for the project data.


Data Type for Project Data


 

Next, create a new API trigger for the Business Process.

 


API Trigger for Business Process


 


API Trigger Details


 

Next, assign the projectData Data Type as an Input to the process under Process Details.


Data Type as Input for Business Process


 

An approval form is added next.  I've kept the form short for the purposes of this demo, only using 3 fields for input and allowing the approver to enter a rejection reason if the project is not approved.


Approval Form


 

In addition, the email details are set for the Approver.  In this demo, I have hardcoded the Approver to be my email address and allowed 3 days for approval.


Approver Message Details


 


Approver Message Details


 

From the Reject port, add a Send Mail step and provide the Reject details.  You can set who the message should be sent to and provide the body of the email as well, including the Rejection reason from the Approval Form.


Rejection Email


 

 


Rejection Email Details


 

Now it is time to add our Action.  From the Approve port on the Form select Actions -> Browse library.


Add Action to Approval


Search for the Project Action and click Add.


Project API Action


 

 

After naming the action, the Process Content fields are mapping as Inputs to the Action:


Context Mapping


 

After the action call, we add a Send Mail step to notify the end user that their project was approved.  The response fields can be used for the project details.


Send Mail


 


Approval Email Details


 

The end result is a simple Process that looks like the following:


Build Process


 

 

With the process complete, it is time to Build and Deploy the project:


Build Project


 


Deploy Project



Testing the New Process


With the process deployed, we can test it from Postman.  The process details can be found under the Process Monitor:


Process Details


 

OAuth authentication is used for authentication to the process:


Postman Authentication


The project data is submitted to SBPA and a successful 201 HTTP code is returned.  The end result is that a new task is generated for the approver.


Postman Testing


Viewing My Inbox on BTP, I can see that I have a new approval request.  The task is approved by clicking the Approve button.


New Task for Approval


The end user receives an email that the project has been approved and is created.  You can add additional data to this email, for example you could add a link to S/4HC and have the user open the project details directly.


Approval Email


The project is now in S/4HC with the default set of work packages ready to be used:


Project in SAP S/4HANA Cloud


Now we have a fully functioning (and tested) business process with an approval workflow and a successful API call to SAP S/4HANA Cloud, public edition via an Action.

In the next blog, a UI will be created in SAP Build App that end users can use to submit their project data.  In this blog, we simulated this step using Postman.

Let me know if you have any questions in the comments.

Thanks,
Marty

 
6 Comments