Programming

SAP Business Application Studio Workflow Modelling

The main intention of this post is to explain the build and deployment process in SAP’s new tool called SAP Business Application Studio.

 

SAP Business Application Studio is the next-generation SAP Web IDE, available on SAP’s multi-cloud environment (the Cloud Foundry). With SAP Business Application Studio, you no longer need a Neo account to develop on Cloud Foundry.

 

SAP Business Application Studio comes with a rich set of tools and templates, including tools for developing workflows with SAP Cloud Platform Workflow Management.

 

Pre-requisite Steps

To proceed with the workflow creation, below are some pre-requisite steps which we need to follow:

  • Have an SAP Cloud Platform account with Cloud Foundry enabled. This can be accessed via a trial account if needed.
  • Access to the SAP Cloud Platform Portal Workflow and Application Runtime, as well as SAP Business Application Studio.
  • Have a configured workflow service, including FLP site with My Inbox and Monitor Workflow tiles (you can get this done by following the steps in this tutorial).

Next, you’ll need to subscribe to SAP Business Application Studio. If you do not know how to do this, refer to this link. Then, find the SAP Business Application Studio in the SAP Cloud Platform Discovery Center.

 

SAP Business Application Studio Dev Space Creation

To open SAP Business Application Studio, log in to the respective Cloud Foundry subaccount and navigate to the subscription section.

 

Note that SAP Business Application Studio is an application, so it will be available at the subaccount level and not per space. Below are the steps to navigate to SAP Business Application Studio:

 

Find the SAP Business Application Studio App

 

Navigate to the subscription section of your Cloud Foundry account, click on the subscription option on the right side and then click “Go to Application.” You will be asked to provide authorization to this application. This is where the subscription comes in handy. When you subscribe to SAP Business Application Studio in your landscape, the relevant roles are automatically assigned to the account.

 

Next, click on the dev space visible in the right corner. Make sure that you select the “SAP Fiori” option and enable the “Workflow Management” extension on the right-hand side as shown below.

 

Enable SAP Fiori and Workflow Management

 

As highlighted above, select the option and enter a name like “myworkflowSpace” in the top right corner, and click on “Create Dev Space.”

 

This will take a couple of minutes, so grab a coffee. Once the created space is shown (like the below screenshots), click on the name you assigned. Note that it should be in the “running” state.

 

Created Space

 

Creation of a Deployable Workflow Module

First we need to create a deployment artifact as a multi-target application (MTA). To do that, open a new terminal from the menu as shown below:

 

Create New Terminal

 

Click on the new terminal option, type the “yo” command, select “basic multitarget application,” and enter a project name, e.g. “mywfapp” as shown here:

 

Enter Project Name

 

Once the folder is created it should contain a “mta.yaml” file, which describes the application. Open the created folder by clicking on the “Open Workspace” option. Once the created folder is found, select it and click on the open button. Sometimes it reloads the application browser, so don’t worry about that. It happened because you changed the workspace.

 

Open Created Folder

 

Steps to Create the Workflow

Follow these steps to create your workflow:

  • Create the workflow module inside the mywfapp folder.
  • Open the terminal and navigate to the mywfapp folder like cd mywfapp.
  • Once more, enter the command yo and this time select the “workflow/workflow module” template.
  • Provide the name for workflow module, something like “mytestwf”.
  • Provide the name to create a workflow with name like “myApproval” and enter the description.

This screenshot illustrates what I’ve described above:

 

StartEvent1 to EndEvent1

 

Now it’s time to provide the sample data. Click “StartEvent” and go to the “Details” tab in the properties section. Click on the checkbox “Configure Sample Content” and then click on “Create File” link.

 

Enter a file name like “mysampledata” and continue as shown below.

 

Enter File Name

 

User Task Creation

To create a user task, click on “Start Event” and select the user task as shown below.

 

Select User Task

 

Next, follow the steps to provide the details of user task:

  • Click on the user task, go to the “details” tab in the properties sheet and enter a task subject (“e.g. myApproval”).
  • The mentioned subject will be visible in the task list in “myInbox” of the workflow task.
  • Also assign a recipient for the task. In the “Users” field, enter your own user ID (for instance your email address, if you are using the SAP ID service).
  • Now select the user task i.e. “myApproval” and navigate to the “user interface” tab as show below.

Select User Interface

  • Select “Type: Form” and click on the “Create File” link.
  • Enter a name, ID, and revision for the new form (e.g. “myApprovalForm”, “1.0”) in the popup.
  • Once the form editor opens, add a new field of type “string” with label “product.”
  • In the “context path” column, enter “${context.product}”. In second field, add the label as “product type” and in the “context path” column enter ““${context.type}”. This expression refers to the “product” attribute in the sample JSON file (i.e. mySampleData.json) which we created in the previous step. See the below figure for more.

Add Labels

 

Navigate to the “decisions” tab and create a title to approve or reject the content. It’s just a dummy approval/rejection decision but in real life scenarios. Based on this condition we can trigger the event or task in the workflow modelling.

 

Approve or Reject Content

 

As shown above “type” decides the color of the button in the myInbox task.

 

Build and Deploy Workflow

In this section, I will show how a workflow, once created, can be built and deployed to the SAP Cloud Platform Workflow engine.

  • Navigate to the right side, right click on the mta.yml file, and click on the “Build MTA” option.

Build MTA

  • This will generate another folder named “mta_archived” under the application, once the MTA build is successful.
  • Please note, if you’re using a trial account, you need to edit the mta.yaml file and change the service plan for Workflow from “standard” to “lite.”
  • Select the “mta_archive” folder, expand the folder, and find an MTA file with the name “mywfapp_0.0.1.mtar”.
  • Click on it and “Deploy MTA Archive” as shown below.

Deploy MTA Archive

  • You will be asked for the API end point based on the region in which you need to deploy the workflow. You might be asked to log in to your Cloud Foundry space to complete this. Enter the right API endpoint depending on your region (e.g. https://api.cf.sap.hana.ondemand.com), your username or email address and password, and select your Cloud Foundry org and space in which you want to deploy the workflow.

Workflow Instance Creation

Once the deployment is done, navigate to the SAP Fiori launchpad, open the Workflow definition tab, and select the workflow (i.e. myApproval) as shown below.

 

Select Workflow

  • Click on “Start New Instance” option as highlighted in the figure above.

Start New Instance

  • Once the instance is created, navigate to the myInbox app either from the “show instance” button or from the SAP Fiori launchpad app myInbox.
  • Approve or reject the task from myInbox in order to mark it as complete as shown below.

Approve or Reject

 

Conclusion

A workflow is a very powerful tool. We can model a workflow in SAP Business Application Studio by creating a user task with some sample data. We could then use this process to automate many tasks and create a flow for scenarios involving multi-step business flow.

 

The modelling of a workflow is the same as it was in the Web IDE, but the build, deploy, and project creation steps are different. In this post, I explained those steps for the end user.

 

I hope this blog post helps to simplify the process of workflow modelling in SAP Business Application Studio.

Rajnish Tiwari
by Rajnish Tiwari

Rajnish Tiwari has over nine years in software development and has extensively worked on database-related technologies like SAP HANA, Kafka, SAP Vora, noSQL, and postgreSQL. An SAP employee, Rajnish currently works on the SAP Predictive Engineering Insights product team.

Comments