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%20Destination%20for%20BTP%20Cloud%20Integration

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%20chatGPT%20to%20generate%20OpenAPI%203.0%20file

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%20an%20Automated%20Process

Build an Automated Process

 

Next click on Actions to create a new Actions project.

API%20Action

API Action

 

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

Add the POST action

API%20Action

API Action

 

 

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

 

Enable%20CSRF%20for%20Action

Enable CSRF for Action

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

Action%20API%20Fields

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%20API%20in%20Action

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%20in%20S/4HC

Project in S/4HC

 

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

Release%20the%20Action

Release the Action

 

Publish%20the%20Action

Publish the Action

 

Published%20Action

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%20Destination%20to%20Build

Adding Destination to Build

 

Now it’s time to create the Business Process.

Business%20Process

Business Process

 

Business%20Process%20Naming

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%20Type%20for%20Project%20Data

Data Type for Project Data

 

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

 

API%20Trigger

API Trigger for Business Process

 

API%20Trigger%20Details

API Trigger Details

 

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

Data%20Type%20as%20Input%20for%20Business%20Process

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%20Form

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.

Email%20Details%20for%20Approver

Approver Message Details

 

Approver%20Message%20Details

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%20Email

Rejection Email

 

 

Rejection%20Email%20Details

Rejection Email Details

 

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

Add%20Action%20to%20Approval

Add Action to Approval

Search for the Project Action and click Add.

Project%20API%20Action

Project API Action

 

 

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

Context%20Mapping

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%20Mail

Send Mail

 

Approval%20Email%20Details

Approval Email Details

 

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

Build%20Process

Build Process

 

 

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

Build%20Project

Build Project

 

Deploy%20Project

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%20Details

Process Details

 

OAuth authentication is used for authentication to the process:

Postman%20Authentication

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%20Testing

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%20Task%20for%20Approval

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%20Email

Approval Email

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

Project%20in%20SAP%20S/4HANA%20Cloud

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.

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x