Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
chris_scott
Active Participant

SAP Flexible Workflow has become the standard workflow approach within S/4HANA.  Its power lies in the capability of defining the workflow rules through the Manage Workflow apps, which moves the definition into the hands of business analysts instead of developers.

With Flexible Workflow, the integration points change, as we can’t simply add a step into the workflow definition.  Instead, the activity is defined within the workflow ‘scenario’ and then the workflow step definition is configured in the Manage Workflow app.

I’ve been investigating how to extend a SAP Flexible Workflow into Microsoft Teams using Looply, such the processes can be approved without managers leaving Teams.

My requirements are:

  1. Managers must be able to approver or reject work in either Teams or through the Fiori Inbox / notification.
  2. Managers must be able to add a rejection comment in Teams or via Fiori Inbox.
  3. The card in teams must be updated if the manager deals with the work using Fiori Inbox.
  4. A notification should be sent to the requestor through Teams, showing the status, the action taken and any comment.
  5. The integration must be instantaneous: we must see the workitem in the My Inbox app at the same time the card appears in Teams.

Scenario

I chose the scenario of Purchase Requisition approval, in an S/4HANA 2020 system, working with scenario WS02000458 – Overall Release of Purchase Requisition.

I have since realized that in S/4HANA 2023 there are more activities available to support resubmission of rejected documents.  In the 2020 version a rejected document is basically cancelled, so a user would need to start again rather than edit and resubmit.

Triggering the Card from S/4HANA

I considered two possible approaches:

  1. Run a background job that looks for new workflow items for a particular task, and then trigger the card creation as part of that job for each item found;
  2. Configure the trigger point as a step within the Flexible Workflow.

I don’t like option 1 because it relies on a job running constantly, so I focused on option 2.

I also needed to consider how the card would be updated if the workflow was actioned within SAP:  So just looking for new workitems for a task wasn’t enough, I would need also to look for actions taken for a particular task.

Option 2 provides the solution to trigger the initial card and any updates: Once the task to approve or reject a workitem is completed, then the workflow should continue to a final step to send updates to Teams.

This leads to a 3-step approach, where we trigger the card in step 1, and send updates to the card in step 3.

chris_scott_1-1709916031989.png

The problem with this approach is that the Agent determination – the part where we figure out who the approver is – has to be executed on Step 2.  We can’t do it on step 1 because that’s a background task.  Also, we can’t trigger the card after step 2, because the workflow waits for user action on that step.

This means that, irritatingly, the point at which we can trigger the creation of the card in Teams is before the system has determined the approver.  Nevertheless, after some head-scratching, I found this to be best approach!

Looply Workflow

We have to configure a workflow in Looply too, in order to control when cards are sent, how they are updated and when calls are made back to SAP.

This is a visual drag-and-drop task, with some data mapping behind each step.

chris_scott_2-1709916032001.jpeg

Since we can reach back to S/4HANA at any point in the Looply workflow, we can make a call to read the workflow agents before we send the Adaptive Card to the approver.

By the time the step is executed in Looply, the SAP Flexible Workflow has moved on to the second step and determined the approver, so that’s available to us in the workflow container.

If, on the off chance that the Looply step is executed first, we can add a simple check to make sure that the Approver is determined before we continue.

chris_scott_3-1709916032013.jpeg

After the Approver Card is created, then Looply awaits a response.

So at this point you have the SAP workflow waiting for a response, and the Looply workflow waiting for a response.

The Looply workflow has 2 branches – one for when the response comes from Teams, and the other for when the response comes from SAP.

When action is taken in SAP, then the ‘External Response’ branch is taken, so we can update the Cards for the Approver and Requestor, and complete the flow.

When the action is taken in Teams, then a second call must be made to SAP to pass in the action and other data (such as the decision comment) and to push the SAP Workflow on to the next step.

Integration Points

This means that there is a total of 4 integration points; 2 from SAP to Looply, and 2 from Looply to SAP. 

chris_scott_5-1709916032018.png

There is a control table in the SAP IMG, (part of the Looply Add-on for S/4HANA or Business Suite) to derive what custom function should be run for each scenario.

chris_scott_4-1709916032016.jpeg

The key logic for these functions is:

Trigger Looply Function:

  • Read workflow container to get additional data if required
  • Read purchase requisition to get data for the teams card
  • Get details of the requestor

Get Approver Function:

  • Get the latest workitem for the workflow
  • Read the recipients
  • Get details of the approver

Resume Looply Function (after SAP action):

  • Get the previous workitem for the workflow
  • Read the action and decision comment from the container
  • Construct the message to appear on the updated Teams card

Update SAP Function (after Teams action):

  • Get the latest workitem for the workflow
  • Add decision comments into the workitem
  • Raise event to terminate the workitem based on the user action
  • Construct the message to appear on the updated Teams card

Adaptive Cards

This just leaves the design of the Adaptive card, which is also done in Looply, using a visual designer. Fields are mapped to data nodes, and conditional logic can be added to control presence.

chris_scott_6-1709916032032.png

Result

This approach delivers on all 5 requirements, and the only development required was 4 small ABAP functions.  Understanding of SAP workflow is the main skill required: No expertise in Teams or integration or any other technology was needed.  I'm not suggesting that this is easy, because we've achieved quite deep integration into the SAP workflow.  But I can't think that there is any easier approach with any other toolset.

Here is the resulting notification to the requestor, one item processed in Teams and the other one in Fiori My Inbox.

chris_scott_7-1709916032038.jpeg

Labels in this area