Skip to Content
Technical Articles
Author's profile photo Abhishek Goyal

Determining SAP Flexible Workflow Agents with Custom Responsibility Rules

Background

With the aim of making workflow configuration simpler, SAP S/4HANA developed a brand-new concept called Flexible Workflow. It is advised that we make use of S/4HANA’s new Flexible Workflow feature.

The preset workflow scenarios and tasks form the foundation of the flexible workflow. This gives users the ability to specify condition-based workflow for various system activities.

SAP provides many such adaptable scenarios in procurement, Settlement Management, Sales etc. However, in many scenarios we don’t get many options when it comes to choosing an approver or agent and standard capabilities like Workflow Initiator or Manager based on HR Hierarchy don’t help with specific, dynamic business requirements.

In order to accomplish that, I have written this blog article to handle an Agent Determination scenario for Condition Contract Release Flexible Workflow which utilize a Custom Responsibility Rule.

Introduction

In the Condition Contract Flexible Workflow scenario, the Standard template provides only one option for setting up the Workflow Approver–the Workflow Initiator Rule. This option isn’t suitable because the Workflow Initiator and Approver can’t both be the same in any Implementation requirement.

In this blog, I will show you how to create and configure a custom responsibility rule to determine the workflow agent for a task.

Pre-requisites

  • The Flexible workflow configuration has been done and is already working (not part of this blog.

Create Custom Responsibility Rule

1. BADI Implementation

We should first implement the BADI RSM BADI STATIC RULE where we will write our code to obtain the Agent based on custom logic before moving forward with building Custom Responsibility Rule using the “Manage Responsibility Rule” App.

Please be aware that it is a Limited Filter Use BADI and that in order to correctly activate it, a Filter value must be provided in the BADI Implementation.

The exporting parameter ET AGENTS in this BADI Implementation Class allows us to enter the agent selected using custom logic. I’ve provided a sample example for your use.

2. Manage Responsibility Rules App

Be sure to complete the following prerequisites before moving on to this step:

  • You have assigned the SAP_BR_ADMINISTRATOR role to your user ID in the development system.

  • You have implemented the RSM_BADI_STATIC_RULE Badi with appropriate filter value.

Select the Custom tab from Manage Responsibility Rules Application on Fiori, then click Create.

 

The “Create” button will prompt you for the package and transport request where you want to lock this rule after you click it. Make sure the BADI filter value set in the previous step matches the Custom Rule name before entering the Custom rule name and its description otherwise you will not be able to save it.

 

Create a parameter using the “Create” button under the Parameter tab and provide the parameter’s name, description, type, and related CDS view. The CDS view and field must be entered if the parameter type is Element. A CDS view should be chosen if the parameter type is Table or Structure. Only whitelisted CDS views are permitted.

Please take a note that adding a CDS view here enables us to obtain information about Condition Contracts from the BADI Implementation Class and use it to create custom logic.

After saving it, we may finish creating the Custom Responsibility rule, but wait—this is where I had an A-ha! moment.

Although we have already put the BADI into use and developed the custom rule, we have not yet assigned it to our Standard workflow scenario and that’s where we are going to utilize the next app ‘Manage Responsibility Contexts’.

Configure Custom Responsibility Rule

With the Manage Responsibility Contexts app, you can use the list of standard responsibility contexts delivered by SAP application teams for agent determination.

You can also extend a standard responsibility context by adding your custom responsibility rule to determine agents that are responsible for your business process tasks, objects, and situation handling.

1. Extending Responsibility Contexts

Be sure to complete the following prerequisites before moving on to this step:

  • You have assigned the SAP_BR_ADMINISTRATOR role to your user in the development system.

  • You have created a custom responsibility rule in the Manage Responsibility Rules app.

 

Choose Extend from this app’s menu after choosing the standard responsibility context and Standard Workflow Scenario ID. Please be aware that if a standard responsibility context has previously been extended, the Extend button will not be available.

 

The “Extend” button will prompt you for the package and transport request where you want to lock this rule after you click it. Once you provide these information, we get the next screen with the extended responsibility context.

 

2. Assigning the Agent Rule to Responsibility Context

We have the ability to link the Custom Responsibility rule to our workflow scenario by assigning it to the Extended Responsibility context under the Agent Rule tab. If you notice the Parent Context ID, it is the Standard Workflow scenario.

 

Here, you can give the agent decision rule a custom responsibility rule. Choose the right custom responsibility rule from the Responsibility Rule ID value help to reveal the parameters for the responsibility rule.

Once it is done, enter a constant value or pick a CDS field from the Data Source value help for each parameter.

 

Once you save it, it will start showing under Extended tab of Manage Responsibility Context app and also in SWDD_SCENARIO.

 

It will be visible in the Manage Workflows for Condition Contracts application in addition to the workflow scenario. This rule can be chosen in the step receiver option, and when choosing the step’s agent, it will apply.

 

I’ll end my blog article here. My focus is on including all necessary steps in this blog article so that it can be helpful to others as well.

I referred and followed the SAP Help Portal documentation to achieve this requirement and below are the direct links:

https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/8308e6d301d54584a33cd04a9861bc52/ec1b8c8f44394c959e02b41c51affd9d.html?q=BAdI%20for%20custom%20agent%20rules%20in%20Responsibility%20Management

If you’d like to ask questions, share feedback and thoughts, please use the comment section and/or post questions in the SAP S/4HANA Cloud community and follow me for further blogs.

 

Thanks,

Abhishek Goyal

Assigned Tags

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