Skip to Content
Technical Articles
Author's profile photo Manuela Kugel

Part 8: Extension Workflow using SAP Workflow Management on SAP BTP

This is part of a series of articles, which describe the steps to integrate an extension workflow using SAP Workflow Management on Business Technology Platform (BTP Workflow) into a Flexible Workflow in SAP S/4HANA OP.

Part 1: Integrating an Extension Workflow on SAP BTP into a Flexible Workflow
Part 2: SAP BTP Cockpit Configuration  for Usage of SAP Workflow Management
Part 3: SAP S/4HANA Backend Configuration to Communicate with SAP BTP
Part 4: User and Roles for SAP BTP Workflow and Flexible Workflow
Part 5: Configure Cloud Connector for Workflow Integration
Part 6: Workflow Scenario with Extension Step
Part 7: Flexible Workflow in Integration Scenario
Part 8: Extension Workflow using SAP Workflow Management on SAP BTP
Part 9: End-to-End Test of Workflow Integration Scenario
Part 10: Problem Solving of Workflow Integration Scenario

Content

1. Enable SAP Business Application Studio (SBAS)
… 1.1. Create SBAS Application Link
… 1.2. Create a Dev Space
2. Create Project
3. Create Workflow
… 3.1. Adjust Properties
… 3.2. Create Form for Approval
… 3.3. Define Start Event
… 3.4. Add User Task
… 3.5. Add Service Task
… 3.6. Define End Event
4. Build and Deploy Workflow
… 4.1. Adapt mta-yaml File
… 4.2. Build
… 4.3. Deploy
… 4.4. Update Workflow Service Instance


1. Enable SAP Business Application Studio (SBAS)

In our context SBAS is used to design the SAP BTP Workflow (external step).

Check, if SBAS application is available:

In SAP BTP cockpit:

  • Logon to your subaccount >> menu Services >> Instances and Subscriptions
  • Check availability of application SAP Business Application Studio:

1.1. Create SBAS Application Link

In case this application is not yet available:

  • Button Create
  • Fill fields:
    • Service: SAP Business Application Studio
    • Plan: standard

This will create a link to SBAS application.

1.2. Create a Dev Space

Start with above described SBAS link

  • Push button Create Dev Space
  • Give a meaningful name, choose SAP Fiori from the list on the left and Workflow Management from Additional SAP Extensions list to the right
  • Button Create Dev Space

  • Wait until the dev space is created and you see the RUNNING status

  • When using SBAS, especially in development environments, check, if you have to start the space. Then, push this button on the right side:

top


2. Create Project

According to SAP Help

Run SBAS

  • Start dev space (if necessary)
  • First time:
    • Create a Project >> Basic Multitarget Application >> Start
    • Name: e.g. CAS_AUDIT
    • Button Finish

  • Right-click the mta.yaml >> Create MTA Module from Template

  • Tile Workflow Module >> button Start

  • Enter path and workflow module name >> button Next

  • Enter workflow name, think of value Name of SAP BTP workflow (sample: casauditworkflowbtp) and description >> button Finish

At the end you have a project structure, which also includes a directory for workflows and an empty workflow file – this is the file with the path and name:

<module name>/workflows/<Name of SAP BTP workflow>.workflow

top


3. Create Workflow

3.1. Adjust Properties

According to SAP Help

In SBAS open your workflow (for path and name of file location see section above).

On the right side you see the Workflow Properties pane.

  • Tab General
    • Give the field Subject a meaningful content, sample: CAS Audit: External Workflow Step on BTP
    • Business Key: a unique identifier of each instance, sample: ${context.no}
    • Optional field Documentation describes the workflow

  • Tab Attributes
    • Add attributes if necessary in the workflow

3.2. Create Form for Approval

The information, which should be displayed to the approver is defined in a form:

  • Use context menu in left side menu >> position mouse on forms directory >> create new subfolder

  • Use context menu >> position mouse on new subdirectory >> New File (which will describe the form)

  • Menu then looks like this:

  • In this form there are tabs Fields and Decisions. Fill appropriate values such as:

Do not ask for the context variables – it is true that we haven’t created the context yet.

3.3. Define Start Event

When creating a workflow, it shows a start and end event already.

  • If you have to create it manually, choose from palette the start event and move it to the canvas

  • Maintain Properties: Name with a meaningful content, optional Documentation as event description

3.4. Add User Task

This is the decision task

  • Add a user task in rectangle shapes area:

  • General tab:
    • Name: meaningful short description, sample CAS Audit: Decision by Partner
    • Optional Documentation: long description for this task
  • Details tab:
    • Subject: e.g. Decision by Partner
    • Description: e.g. Partner approval
    • Recipients: fix or variable values for person or group, sample: your email address
    • Set Show in workflow log
    • Set Allow forward
  • User Interface tab
    • TypeForm
    • File Name: push button Select and choose from list the form file created above
    • Revision: start numbering as you like it, sample: 1.0

3.5. Add Service Task

According to SAP Help

You need a service task to complete the workflow in the backend system. This task will trigger a service, which sends an event to the flexible workflow. This finishes the external task. Then the flexible workflow in SAP S/4HANA system can continue.

  • Create a new step in SAP BTP workflow of type Service Task. Click in rectangle shapes area to see the different types of activities:

  • General tab:
    • Name: a meaningful name for the task
    • Optional Documentation: describe the task
  • Details tab:
    • Destination: destination name of SAP S/4HANA from SAP BTP
    • Choose a Service from: Others
    • Path: /sap/opu/odata/sap/SWF_CPWF_NOTIFICATION_SRV/ProcessCompleted?workflowInstanceId=’${info.workflowInstanceId}’
    • HTTP Method: POST
    • Path to XSRF Token: /sap/opu/odata/sap/SWF_CPWF_NOTIFICATION_SRV/

3.6. Define End Event

Similar to the start event, the end event is drawn already.

  • Check Name and Documentation fields in properties panel

Finally, the workflow should look like this:

top


4. Build and Deploy Workflow

According to SAP Help

4.1. Adapt mta-yaml File

  • Open mta.yaml file
  • Check or change the instance name (sample: wf_standard_service) as shown below in red boxes

4.2. Build

According to SAP Help

  • Use context menu on mta.yaml file >> Build MTA Project

An mta_archives folder is added to your application, with a deployment-ready multitarget application (MTA) archive .mtar file.

4.3. Deploy

According to SAP Help

  • Use context menu on newly generated mtar file (sample: CAS_AUDIT_0.0.1.mtar) >> Deploy MTA Archive

  • Confirm (or change) endpoint:

  • Insert your email:

  • Enter your password to Cloud Foundry
  • Result:

  • Select your organization from value list, use value Org Name
  • Select Space from value list, use Space Name, sample: WF_MKU
  • Terminal (at the bottom of SBAS) should show success message like this:

You can check the availability of newly created service key in SAP BTP:

  • Go to your SAP BTP subaccount
  • Menu Services >> Instances and Subscriptions
  • Check in section Instances the line with instance instance name (sample: wf_standard_service)
  • In column Credentials you can find the key. This key name must be identical to what was shown in above screenshot, line “Creating service key…”

Build and deploy steps must be processed each time the workflow changes.

4.4. Update Workflow Service Instance

According to Procedure section of SAP Help

This is a one-time step.

  • Go to your SAP BTP subaccount
  • Menu Services >> Instances and Subscriptions
  • Check in section Instances the line with instance instance name (sample: wf_standard_service)
  • Choose dots button in this line >> push button Update

  • In the new popup do not change anything on the first page >> button Next
  • Add the following code in Json text field (eventually check on SAP Help page for newer suggestions) >> button Next
{ 
    "authorities": [
        "WORKFLOW_INSTANCE_START",
        "WORKFLOW_DEFINITION_GET",
        "WORKFLOW_INSTANCE_GET",
        "WORKFLOW_INSTANCES_UPDATE",
        "WORKFLOW_INSTANCE_CANCEL",
        "WORKFLOW_INSTANCE_GET_ERROR_MESSAGES",
        "WORKFLOW_INSTANCE_GET_CONTEXT",
        "WORKFLOW_INSTANCE_GET_EXECUTION_LOGS",
        "MESSAGE_SEND",
        "TASK_GET"
    ]
}
  • Button Update Instance

=> Conclusion: now, the external step of our Flexible Workflow can be addressed. We should be excited, if the whole end-2-end process is working. Let’s check this in the naxt part.

top


>> Next: End-to-End Test of Workflow Integration Scenario

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.