SAP Builders Blog Posts
Learn from peers about their low-code journey and write your own blog posts to share your thoughts and experiences as you become an SAP Builder.
Showing results for 
Search instead for 
Did you mean: 
Developer Advocate
Developer Advocate

During the keynote at SAP TechEd, I delivered a short demo of how I can build an app with SAP Build Apps that authenticates to BTP, uses destinations to get SAP S/4HANA and BTP service data, and uses the same destination functionality to trigger workflows on SAP Build Process Automation and to get the status of those workflows.

The first 2 tasks would generally be done by an an IT administrator or developer: enabling SAP Build and building the services and destinations.

After that, the remaining tasks would be done by a business user, perhaps with a little help from a developer (especially for the exact setup of the REST API data resource for Process Automation). 

IT Department

 Enabling SAP Build 

I will write another blog on how to set up SAP Build, since at the time of this writing the product had not been released and the exact way to set up was not yet published. And I don't like to write about anything that I don't try myself.

But I will give you an outline of what's required, which should be enough to get started.

  1. Run the boosters for at least SAP Build Apps and SAP Build Process Automation.
  2. Assign the "Build" roles, at least for SAP Build Apps and SAP Build Process Automation.

Again, I will write again here and provide the documentation, as well as my experience setting this up on the new landscapes released today.

Note that you can also use a US10 trial account, but again, I do not have all the details at this time.


Creating Destinations (IT)

For the project I created 2 "data" destinations:

  • BTP service
  • SAP S/4HANA Cloud

You are basically on your own for these, since I cannot give you my SAP S/4HANA system or my BTP service. You will have to get your own SAP S/4HANA service (not sure if there is a trial system), and instead of the BTP service you can use whatever free service, like from TripAdvsor or whatever.

I will show you the destination configuration, since you must have the following properties (requirements are changing all the time so some properties may no longer be needed):

Additional PropertyValue

For the SAP S/4HANA Cloud system, you have to create a communication user (this tutorial might also help, but this is beyond the scope of SAP Build) and give it the rights for the Business Partner APIs. 


For the BTP service with the activities list, my colleague created an CAP service without authentication.


The last destination you need is to the Process Automation APIs. I am told this is now created automatically when you enable Process Automation with the booster. But here's how to do it manually.

You have to go to your SAP Process Automation instance (not subscription), and make sure to create a service key: Services > Instances and Subscriptions, and click on your instance. If you don't have a service key yet, click on Create and create one.


On your service key, click the three dots and choose View.


You will get the service key information, including the information you need for the destination.


You will use this destination to trigger processes and get information about processes.


Business User

Once IT has set up their part, business users can go ahead and build their apps.

Building the SAP Process Automation

I created a simple process, that had a condition and a single approval step. 


I added input parameters for data I needed to receive from my app.


I added mail steps for 2 reasons:

  • Just to notify me if the process was triggered, and its status.
  • At the end of the process, I needed a way to tell if the process was approved or not, and currently there is no way to specify context or set parameters in the end steps to know if it was approved. So I added mail steps, and later when I got the execution log I could check which mail step was executed. 

And this was the finally condition definition:


Building the UI

I will not go into detail about the UI, since it did not reflect any special new capabilities of the new SAP Build. Feel free to comment if there is something in the UI we should that was not clear.

Note we used:

  • Custom navigation
  • Opacity property to be able to show the activities both as a list and tiles
  • Formula for defining colors so we can show different colors if the activity is approved or not   

Connecting to the Data

This is quite simple. You go to the Data tab, and click Add Integration > BTP Destinations.


You get a list of destinations. Select one, and now you can browse data. When you're ready, click Install Integration, then select the entities you want to enable and click Enable Data Entity. Then click Save.

You will now see the new data source in the Data tab.


And now you can create data variables with it, or configure data components, as you could with regular data sources.

Setting Up Connection to Process Automation

Again, this may be set up for you when you install SAP Build, but in case it's not, here's how you would create it from the destination for connecting to the Process Automation APIs (IT did this earlier).

Go to the Data tab, and select SAP BTP Destination REST API Integration:


You need to now configure the Base part and the Create part.


For the Base part do the following:

  1. Give the data resource a name.
  2. Select the destination for connection to SAP Build Process Automation API.
  3. Under Resource schema, add the parameters that are required by your process. For example, I defined input parameters for activity, price and other stuff. These need to be defined here. The parameter names are case-sensitive.
  4. This should be automatic, but check under Common request headers that you have defined an Authorization header and it is set to the formula:
    • "Bearer " + query.authConfig.authToken

For the Create part do the following:

  1. Enable the Create method.
  2. Under Request headers, set the following: 
  3. Under request body mapper, set to the formula:
    • ENCODE_JSON({ "definitionId": "<your process name>", "context": query.record })​

Replace <your process name> with the name of your process. Go to SAP Build Process Automation, and then go to the Monitor tab > Manage > Processes and Workflows, and find your deployed process. To the right you find the ID of the process. This is the ID to put in the formula above.


Triggering a Process

To trigger a workflow, you just need to create an event and then run a Create Record flow function.

I created a button, and to the tap event of the button, I added a Create Record flow function.


Configuring the flow function is really simple:

  1. For Resource name, select the data resource we created earlier for calling the Process Automation API.
  2. For record, bind the parameters as needed to pass the values our process needs. I had to use wrap some parameters in the NUMBER function  to make sure their type was understood by Process Automation.


Getting Status of the Process Instance

For getting status of a workflow, the path of the API is different so I created a separate data resource based on the same Process Automation destination.

The only differences were:

  • In the Base part, instead of passing the parameters for triggering the workflow, I passed only the ID of process instance, an ID that is returned when you trigger the workflow.
  • For the Create part, the HTTP method is GET, no request body mapping is required, and the URL path needs to be defined, to the following (spaidinput is the name I gave to the ID parameter).
    • "/" + query.record.spaidinput + "/execution-logs"

To actually get the status, I had to do a workaround.

First I created a button to trigger the API call, which triggered the Create record flow function. That flow function pointed to the data resource I just described, and the single input parameter was set to the current process instance ID (which I saved when I triggered the workflow). 


The API call returns a JSON list that represents the execution log of the process instance.  


In my process, I defined separate Mail steps if the process was approved or if it was rejected, So I used a formula that searched that list (which I saved to a page variable) to see if I got the activity for approval or for rejection. 





NOT(IS_EMPTY(FIND(pageVars.Workflow, item.subject == "Approved Mail")))