Skip to Content
Technical Articles
Author's profile photo Christian Loos

Getting started with Workflow in SAP Business Application Studio

Introduction

SAP Business Application Studio is the next-generation SAP Web IDE, available on SAP’s multi-cloud environment (Cloud Foundry).

With Application Studio, you no longer need a Neo account to develop for 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.

In this blog, we will show how to create a first Workflow application in the Cloud Foundry environment of SAP Cloud Platform.

 

Pre-requisites

Before we continue, please make sure you have the following things in place:

  • SAP Cloud Platform account with Cloud Foundry enabled (Trial also works)
  • Entitlements for Portal, Workflow, Application Runtime and Application Studio
  • Workflow service is configured, including FLP site with My Inbox and Monitor Workflow tiles (follow the steps in the tutorial)
  • Application Studio is configured (see documentation)

 

Create a Dev Space

Note: If you have followed the tutorial to deploy the FLP site, then you can skip this step, and just continue with creating the application in your existing workspace in Application Studio

If you have not open Application Studio yet, you can start it from the “Subscriptions” tab in your Cloud Cockpit, and create a new Dev Space.

Make sure to select “SAP Fiori” and enable the “Workflow Management” extension on the right hand side.

Once the dev space is ready (it might take a while), go ahead and open it.

Finally you need to open a new workspace. Select the “projects” folder and proceed.

Create MTA application

For creating a deployment artifact, we need to create an MTA application.

Open a new terminal window and enter the “yo” command.

Select “Basic Multitarget Application” and enter a project name, e.g. “myworkflowapp”.

A new folder with the project name will now appear in the Explorer view.

It contains a “mta.yaml” file, which describes the application.

 

Create Workflow module

We can now proceed with creating a Workflow module within the MTA project.

In the terminal, go into the application folder below the “projects” folder via the command “cd <folder name>”, e.g. “cd myworkflowapp”.

Then enter “yo” again and select the “workflow/workflow Module” template.

Give a name for the workflow module (e.g. “myworkflow”), the workflow itself (e.g. “SimpleApproval”) and a description.
Confirm to overwrite the “mta.yaml” file.

Now you should see the newly created workflow in the editor.

To fill it with sample data, click on the Start event 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 (e.g. “sampledata”) and continue.

 

Adding a User Task

Let’s add a user task to the workflow for a simple approval.

From the palette, select Tasks -> User Task and click on the connector between Start and End Event.

Click on the User Task, go to the “Details” tab in the properties sheet and enter a task subject (“e.g. Approval”).

The subject will be shown in the task list in My Inbox.

You also need to 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).

If you are using a custom Identity Provider, you need to enter the what is configured as the “Subject Name Identifier” (see documentation).

Finally, we need to define the form, which will be shown when the task is opened in the My Inbox.

In the user task properties, go to the “User Interface” tab.

Select “Type: Form” and click on the “Create File” link.

Now enter a name, ID and Revision for the new form (e.g. “SimpleApprovalForm”, “1.0”).

Once the form editor opens, add a new field of type “String” with label “Product”.
In the “Context Path” column, enter “${context.product}”.
This expression refers to the “product” attribute in the sample JSON file which we have created in the previous step.

In the Form editor, switch from “Fields” to “Decisions” and add a new decision called “Approve”.

 

Build and deploy

We are now ready to build and deploy the Workflow.

Right-click on the “mta.yaml” file in your main application folder and select “Build MTA”.

Note: In case of Trial, you need to edit the mta.yaml file and change the service plan for Workflow from “standard” to “lite”.

Once the build is completed, a new folder “mta_archives” will appear under your application folder.

Right-click on the .mta file and select “Deploy MTA Archive”.

Note: You might be asked to log in to your Cloud Foundry space. Enter the right API endpoint depending on your region (e.g. https://api.cf.eu10.hana.ondemand.com), your username and password, and select your Cloud Foundry org and space.

 

Run the workflow

After deployment has finished, open the Fiori Launchpad site which contains the Workflow applications (refer to the pre-requisites section).

Open the Monitor Workflow (Workflow Definitions) application and select the “SimpleApproval” workflow definition.

Click on “Start new instance”.

Now, go back to the home page and open the “My Inbox” application.

There should be a task “Approval” with a form, showing the product name and an “Approve” button.

 

Summary

You have now modeled your first workflow with SAP Business Application Studio on Cloud Foundry.

SAP Business Application Studio is a very powerful development environment, tightly integrated with the SAP Cloud Platform and well suited for developing business applications.

There is lots more to explore, for instance creating a Fiori SAPUI5 component or calling other services.

We will follow up on this in a future blog.

Assigned Tags

      15 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Mariajose Martinez
      Mariajose Martinez

      Hello Christian! Thanks for this blog. We need more info about this now that the Neo environment and Web IDE are going to disappear!

      I follow you steps but had some errors at the deployment.  I can image that it is because I still don’t have the FLP with the workflow apps tiles configured. I tried to follow these steps but I cannot find the Fiori Launchpad module inside the Fiori project as the documentation says. https://help.sap.com/viewer/e157c391253b4ecd93647bf232d18a83/Cloud/en-US/97c079f9317c42bba31cc9ca9d4cc7c3.html Could you please document step by step about how did you do this? or share your projects? I would be so much easier to understand how to do it.

      Thank you in advance!

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi Mariajose,

      The easiest and fastest way to set up the FLP is to import the sample project from the starter tutorial:
      https://developers.sap.com/tutorials/cp-starter-ibpm-employeeonboarding-1-setup.html#ae14368a-03fb-42fe-841b-e8d94b5dd98e

      After import, make sure to check the mta.yaml for the right service plans - "lite" for Trial, "standard" or "workflow" for a paid plan (you can check the entitlements in your Cloud Cockpit account).

      Regards,
      Christian

      Author's profile photo Mariajose Martinez
      Mariajose Martinez

      Thank you for your fast reply Christian!

      I found a simpler way to enable the FLP. I did something similar as the link you shared with me.

      What I did was to enable both Workflow Management in the entitlements and later started the Booster. After having this process done, I went to the Workflow Management in the Subscriptions and clicked on "go to application": this link is the FLP already integrated with my default workflow instance. This was without the need to import any other project :). I hope this can be useful for any other developer around!

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Yes, this will work for the simple example above.

      However, if you want to have a start form, or want to use SAPUI5 to build the task UIs, you'll still need to have a separate FLP site, as those cannot be integrated into the Workflow Management app.

       

      Author's profile photo Max Schnürle
      Max Schnürle

      Dear Christian Loos ,

       

      do you know if there is a way how to start a workflow instance from a fiori element application?

       

      Best Regards

      Max

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi Max,

       

      You can start it via the Public REST API.

      So if you can add some custom controller code to your Fiori Elements application you can start the workflow instance via JavaScript code.

       

      Regards,

      Christian

       

      Author's profile photo Kai Umeki
      Kai Umeki

      Dear Christian Loos

      Thank you for posting this wonderful blog.
      I deployed a workflow based on this blog and got the following error.
      Could you please tell me what is the problem with this?

      Creating service key "approvals-workflow_mta2-credentials" for service "workflow_mta2"...
      Uploading content module "approvals" in target service "workflow_mta2"...
      Deploying content module "approvals" in target service "workflow_mta2"...
      [approvals] [ERROR] Deployment of purchase.workflow failed due to invalid response code 422 from runtime server, Response Details: {"error":{"code":"bpm.workflowruntime.rest.validation.error","message":"Validation of the workflow model failed.","details":[{"severity":"error","message":"Mandatory attribute(s) 'timeDuration' on element 'idba6ebcbd-5f98-45a9-aa84-4988add22d70' not available. Make sure that it has been provided.","modelElement":"idba6ebcbd-5f98-45a9-aa84-4988add22d70","modelElementName":null}]}}
      [approvals] [FATAL] Deployment of purchase.workflow failed , Error Details: while trying to invoke the method org.springframework.http.ResponseEntity.getStatusCode() of a null object loaded from local variable 'response'

       

      I would appreciate it if you could tell me.

      Sincerely,

      Kai Umeki

      Author's profile photo Christian Loos
      Christian Loos
      Blog Post Author

      Hi Kai,

       

      Do you get a validation error in the editor / model? Sounds like the duration on a timer or boundary event is not correctly set.

      If there is no validation error in the editor please create a support ticket.

      Regards,

      Christian

      Author's profile photo Kai Umeki
      Kai Umeki

      Dear Christian

      Thank you for replying.

      I tried to deploy the workflow again, and I don’t know why but it succeeded.

      Anyway, thank you for your answer.

      Sincerely,

      Kai Umeki

      Author's profile photo Kajal .
      Kajal .

      Hey Christian Loos ,

      Thankyou for this amazing blog.

      Do you know how to handle user input data in start forms in SAP Workflow?

      Thanks,

      Kajal

      Author's profile photo Javier Grande Gonzalez
      Javier Grande Gonzalez

      Hi

      Can you help me why to make a Deploy MTA archive, with workflow, send me error:

      Deploying content module "workflows" in target service "workflow"...
      [workflows] [FATAL] Deployment of file Id 61f4e020-1cbc-11ec-8335-e53bb5bf19de Failed, Error details: while trying to invoke the method com.sap.bpm.wds.core.model.WorkflowModuleContent.getSubcontents() of a null object loaded from local variable 'obj'
      Content deployment for module "workflows" failed. Download the logs "workflows_workflow" via the dmol command and check them for more information.

      Author's profile photo Ertuğrul Pehlivan
      Ertuğrul Pehlivan

      Hi Javier,

      i got the same error too. did you find any solution ? 
      
      
      
      Author's profile photo Ertuğrul Pehlivan
      Ertuğrul Pehlivan

      Hi again,

      I solved the problem. Open a new terminal page and type the command in the 3rd line above.
      (Use "cf dmol -i 1d00fc5f-22a3-11ec-87c8-eeee0a9b2a4c" to download the logs of the process.)
      Then open the Capex-00_wm_workflow.log file and detect the error.(1st picture).
      My error was due to a space in the condition.(2nd picture).
      When I delete the space there and build,deploy again, there is no problem.(3rd and 4th picture)

      1.picture2.picture3.picture4.picture

      Author's profile photo Veeresh S
      Veeresh S

      Thank you

      Author's profile photo Anupam Alok
      Anupam Alok

      Hi,

      Have you created the custom UI for MyInbox using SAPUI5 Component, not by using form? Please guide the step

       

      Thanks,

      Anupam