Skip to Content
Technical Articles

SCP Neo Workflow & Business Rules: Simple Use Case

Hello,

When using SAP® Cloud Platform Workflows, in most cases i get a question regarding Business Rules (and if they can enhance the Workflow experience). There are already some great materials about them both working together, like this one here, but my GOAL here is to create a very simple use case scenario that covers them both working together.

If you don’t know much about SAP® Cloud Platform Business Rules, you can get more info here. But just to make it “simple”, Business Rules (as the name states) is: an Intelligent Business Process Management service that lets you digitize and automate decision making. It encapsulates dynamic decision logic from application logic. It also provides web-based tools to model business vocabulary and decision interfaces to integrate with SaaS applications and business services.

So what we’re gonna do it here today is: Create a simple Rules Project to decide the Approver ID based on a input condition (Currency ID), and use it in a Workflow to decide ho is going to approve.

PS: I’m using a Neo Trial Account.

Also recommend another tutorial on Business Rules here. This tutorial covers most of the steps to setup your Business Rules service in Neo.

So now let’s start with the Business Rules part, going to the Manage Rules Project:

Created a DemoApprovers rule project:

Now, let’s create 2 local Data Objects: USR (that represents the User) and CURR (that represents the Currency field as the input):

Everything using String Data Type, really simple… Don’t forget to Save/Activate everything.

Now, let’s create a Local Rule (GetApprover):

Here is where the logic resides, where if the Currency CURR field equal ‘USD’ then it gives one User ID and if else give other User ID. Create the same way (by replacing the User with yours).

After everything is done, select Implement button:

Before, create a Rules Service(CURR Input and USR Result) and Rules Set like this:

After Activate everything, now let’s test our scenario using Postman:

PS: Don’t forget to get the Token first at /rules-service/v1/rules/xsrf-token

Now, sending a Post request to /rules-service/v1/rules/invoke?rule_service_name=DemoApprovers::GetApprover and passing the Payload below:

{
    "__type__": "CURR",
    "CURRENCY": "EUR",
    "TEXT": "EUR - Euro"
}

We get the Else condition (as it’s not USD):

Now sending the payload below:

{
    "__type__": "CURR",
    "CURRENCY": "USD",
    "TEXT": "USD - DOLLAR"
}

We get my User ID:

So now we’re ready to create the Workflow.

First, going back to your destinations at your subaccount, notice the bpmrulesruntine destination. I’m creating a copy passing Basic Auth (*_CLONING) as the current one does not work out of the box for this purpose.

First, you haven’t created a Neo Workflow yet, i suggest you to follow this tutorial here. As it will cover all the basic steps as well. Now, creating a Workflow:

Like this:

User Step form:

And the Service Task (with the cloned destination) like this:

If you want the project, on get it here on Github.

After the Workflow deploy, let’s create a instance with the payload below:

{
    "__type__": "CURR",
    "CURRENCY": "USD",
    "VALUE": "1000",
    "FROM": "BRL",
    "TEXT": "USD - DOLLAR"
}

As it’s USD, arrives in My Inbox for my User ID:

Looking at the Workflow Log:

It executed the Business Rules service, got the Approver (Return.UserID) and returned, generating the Workflow context below:

After approval, Workflow ends with success.

Hopefully it can help you somehow, as it’s just a “base” project with simple functionalities to show the power of Business Rules and Workflow working together.

Enjoy!

EDIT:

If you combine with my previous tutorial here, you can start this Workflow in one call! See it in action here:

 

Regards.

 

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