cancel
Showing results for 
Search instead for 
Did you mean: 
dan_wroblewski
Employee
Employee

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
AppgyverEnabledtrue
HTML5.DynamicDestinationtrue
WebIDEEnabledtrue

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. 

dan_wroblewski_1-1668350360690.png

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

dan_wroblewski_2-1668350486649.png

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.

dan_wroblewski_0-1668350940136.png

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

dan_wroblewski_1-1668351153895.png

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

dan_wroblewski_0-1668350686850.png

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. 

dan_wroblewski_0-1668437335223.png

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

dan_wroblewski_2-1668437464108.png

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:

dan_wroblewski_1-1668437433723.png

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.

dan_wroblewski_0-1668351856756.png

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.

dan_wroblewski_1-1668352011858.png

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:

dan_wroblewski_2-1668352172553.png

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

dan_wroblewski_1-1668434742495.png

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: 
    Content-Typeapplication/json
  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.

dan_wroblewski_3-1668435592444.png

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.

dan_wroblewski_0-1668435788659.png

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.

dan_wroblewski_0-1668438186138.png

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). 

dan_wroblewski_0-1668436615735.png

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

dan_wroblewski_1-1668436812875.png

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")))

 

 

 

 

 

 

 

 

 

 

 

 

 

6 Comments