Skip to Content
Technical Articles

SAP Workflow Rule based Dynamic Agent determination (using BRFplus Decision Tables)

Objective

The objective of this blog is to detail the process of Dynamic Agent determination using BRFplus Decision Tables.

Pre-requisite

The reader must be aware of the basic workflow design terminologies and SAP BRFplus basic concepts.

In day to day scenarios, the need arises to determine workflow approvers or agents during run-time based on some rules or conditions.

If the rules are dynamic in nature and changed frequently based upon business processes then it becomes difficult to maintain or change agent assignment rules in production environment directly.

Consider a scenario, where we want to define workflow agents based on Item category group or material type or specific sales area or specific regional approvers. Or we may want to define approvers for specific discounts given on products e.g. If more than 10% discount then workflow request should be routed to specific approver.

What could be the best possible way to define easy Agent determination rules in easier and simplest way?

What if these rules are required to be changed so often?

What if these agent determination rules needed to be reflected in production environment quickly without any code changes?

In similar situations above, BRFplus and Business Workflow integration can be best utilized.

In such scenarios, BRFplus decision tables can be utilized for maintaining Agent determination rules in production environment.

  • SAP Business Workflow:

An agent is someone who can receive work items in their inbox and perform actions on them.

From Organizational Management area, some agent determinations are triggered, with the help of functions which search the leading position, the higher level manager, etc. The involvement of the organizational management here can be either dynamic in the rule through some evaluation paths, or defined for example through responsibilities.

SAP Business Workflow SAP Business Workflow can be used to define business processes that are not yet mapped in the SAP system. These may be simple release or approval procedures, or more complex business processes such as creating a material master. SAP Business Workflow is particularly suitable for situations in which work processes have to be run through repeatedly in which the business process requires the involvement of a big number of agents in a specific sequence.

  • SAP Business Rules Framework (BRFplus):

BRFplus is the tool of choice for developing business rules in ABAP. BRFplus is a business rules engine.

There are many benefits of Business Workflow and BRFplus integration. In this blog, we will see how BRFplus decision tables can be utilized for Dynamic Agent determination.

In BRFplus decision tables, we can maintain rules that is define outputs based on specific input conditions. These decision tables are easily maintainable in production environment as well.

Usage of BRFplus gives the flexibility to add new or modify existing “agent determination rules” inside decision tables without any need to integrate or modify the code and thereby directly deploy the changes.

Technical step by step process:

So let us discuss end to end example, to trigger BRFplus from Workflow, derive agent and set up the agent for the next workflow step during run-time.

Let us consider the material creation and change workflow, where we want to set agent based upon material type (MTART) field value.

In this scenario, we will consider simple example. We can design more complex rules and rule sets in BRFplus as per specific requirement.

Below is the requirement we want to take Material type as input from workflow, find relevant agent from decision table and set this agent for next workflow user decision step.

Material Type User (Approver/Agent)
Finished Product A
Raw material B

Based upon the material type, workflow request should be routed to relevant approver.

Let us see step by step process to integrate BRFplus & Business Workflow to derive an agent during run-time.

1. Let us first create BRFplus application:

2. Create 2 Data objects: ZMTART & ZUSER and activate the same.                                                                                                                                                         

3. Create new BRFplus function which needs to be triggered from workflow.

4. Add already created data objects in the context of the function. Save and Activate.

5. Create Decision table —- Select Object Type as ‘Expression’ and Expression type as ‘Decision Table’.

6.  Insert columns from context data objects and activate the decision table. Maintain rules in      decision table. See below example, if the material type is “Finished Product” then material creation workflow request should be routed to User “A” for approval.

7. Now create a rule set to process decision table. Go to the function and create a rule set.

8.  Now inside rule set, add new rule to process rules inside decision table. Click on create rule.  In then condition, add — process expression — select — (select the decision table which was created earlier).

The rule should look like below.

9. Rule set assignment to function should look like below. Test run can be done in simulation mode to see whether rules are executed properly from decision table.

10. Now BRFplus designing part is complete. Let us start with workflow definition to trigger BRFplus function and read the user for specific material type, also set the user as agent for the next user decision step in the workflow.

11. Go to transaction SWDD.

12. Let us start building workflow and integration with BRFplus.

13. Workflow will have two steps –

  • Activity Step – To trigger BRFplus function, execute the rule set and read the output (Approver or Agent ID) from BRF decision table. This step will determine approver during run time from BRFplus decision table based on the input parameter Material Type (MTART).
  • User Decision Step – To ‘Approve’ or ‘Reject’ the request in workflow.
  • Complete workflow should look like below:

14.  Go to transaction SWDD.

15.  Create two workflow container elements à ZMTART-Material Type (input to BRF decision table) & ZUSER-Approver ID Agent (output of BRF decision table).

16.   Now create Activity Step: Inside the Activity Step — Create new task to include BRFplus function.

17.    Add the details for Task as below.

18.     Now the next step is binding — binding of workflow containers with BRFplus function Input/output parameters. Here in this scenario Material Type (ZMTART) would be an input from workflow to BRFplus decision table, BRFplus will return output i.e. User ID (ZUSER) from decision table to which workflow request should be routed.

19.      Add the user decision step — to APPROVE or REJECT the workflow request. In “Agents” tab, select “Expression” to set the Agent as per BRFplus rules (decision table) during run-time.

20.    After this activate the workflow. Workflow is ready for test.

21.    Let us test the workflow now and see if the request is getting routed to the Agent which is configured in BRFplus decision table. Click on test workflow button and provide inputs.

22.    You will see the message.

23.    Now check the SAP inbox of the Approver or Agent, workflow request should be routed to the user as per the rule in BRFplus decision table.

24.    Either approve or Reject the request.

25.    We can check the workflow log to validate whether the correct output was returned by BRFplus.

26.     Workflow log shows, we received expected result from BRFplus.

So here we are done with Dynamic Agent determination for SAP workflow with the help of BRFplus rules.

Now some benefits of using Dynamic Agent determination/workflow building in combination with BRFplus :

  • Rule based workflows are always preferred over the conventional SAP business workflow, as it is easier to change the rules in BRFplus, also easier to maintain Agents to be determined dynamically.
  • Business rules keep changing, it is always easier to change or maintain the new rules without any changes in workflow definition or code changes.
  • Calculations, validation and derivations can be easily performed inside BRFplus and can be utilized in workflow.
  • One more advantage is that BRFplus and Business workflow integration works both the ways, BRFplus can be triggered via workflow or workflow can be triggered via BRFplus.

I hope this blog gave helpful insight on how to derive agents during run-time using BRFplus rule sets.

1 Comment
You must be Logged on to comment or reply to a post.