Skip to Content
Author's profile photo Faisal PC

BRF Plus-A real time example

Hi All,

 

Here is a blog on BRF Plus for beginners.

 

What is BRF Plus:

 

“BRFplus (Business Rule Framework plus) is a business rules management system (BRMS) offered by SAP AG. BRFplus is part of the SAP NetWeaver ABAP stack. Therefore, all SAP applications that are based on SAP NetWeaver can access BRFplus within the boundaries of an SAP system.

how you can create a simple BRF Application for the following use case.”

 

I believe the above definition would have confused you a bit. Being an SAPier, where and when we can use a BRF Plus application. That is all we want to know. ๐Ÿ˜Ž . Let’s come back to the real world where we have lots of RULES to obey…And BRF is all about rules.

 

Consider an application to determine the salary of applicants to a job position where the salary and designation of the applicant are getting calculated based on certain rules. And those rules are prone to change. Meaning, in a year itself, there can be many rules for determining the salary. So it’s always advisable to segregate rules from the code.

 

We can still go with normal IF ELSE conditions. But when the frequency of change in rules if high, let’s leave that to a separate application where even a lay man can manage the rules.

 

I will show you how to create a normal BRF application for the above requirement. Our use case is,

 

Determine the salary for an employee based on the company he is coming from and years of experience he has.

 

In this application, we will see the creation of,

 

1) Data Objects

2) Expressions

3) Functions

4) Rule sets

5) Actions

 

Let’s say that a company decides to recruit people from outside and the process of recruitment is already done. But the salary discussion is yet to happen and they have a list of people from different companies as applicants. So, they decide to create a BRF Plus application and it will run with input of company name and years of experience.

 

For this purpose, they have a list of values relevant for this. I will categorize them as 3 tables as in the picture.

 

Tables.JPG

 

As in the above picture, the rule is->If the applicant is belonging to a tier 1 company, then he has to have the experience of 2 years to be an SE while for an applicant from tier 2 company needs 3 years. Also, the salary for the tier 1 company applicant is more than the tier 2 company(Just for this example. May not be true in real life. ๐Ÿ˜‰ ).

 

So, the rules are set and we know what needs to be done. Now we can go to BRF workbench with tcode BRF+ or BRFPlus or FDT_Workbench.

 

BRF Workbench.JPG

 

I am clicking on ‘Create application’.

 

Create application.JPG

 

Keep in mind that I have created as Local object. If we select the storage type dropdown, we can move this across landscape. Following are the types.

 

System-> transportable objects which should not be changed in your system environment.

Customizing-> transportable objects which allow changes.

Master Data-> objects which are local by default and cannot be transported.

 

Click on save and activate. Then,

 

1) Creation of Data objects->Elements/Structures/Tables.

I am creating all data objects required for this example here.

 

Element creation.JPG

I can either create elements one by one or can go with Elements(Mass creation).

 

Activate all the data elements. (I created an internal table also to hold the values from db table.).

Data objects.JPG

2) Create expression required for the function.

As I mentioned at the beginning, we have 3 tables out of which 1 we will make as db table and other two will be created as decision table. Just for showing their operations I am keeping so.

 

So, here we need 2 decision tables and 1 db table. For fetching data from DB table, we would need to create a DB lookup also.

 

Decision table.JPG

I give the input and output of the decision table.

Save it and activate. Now the table is ready. Here we can insert the values to the table.

 

 

In the same way, create one more decision table called YEARS_TABLE with fields as Years of experience, Tier and designation. Make the entries.

 

 

I already have a DB table created and it has the following values.

 

 

Now go with creation of DB lookup in the same way we created the decision table in expressions by choosing Database Lookup.

 

 

Now we are done with the creation of expressions.

 

3) Create functions->This will be the one we will use in our ABAP program/buttons/BADIs etc. It’s very similar to FM or methods of a class.

 

 

Now go to tab ‘Assigned Rulesets’ and create a rule set. And then assign the rules to the rule sets.

 

Here I assign rules one by one. After all the assignment, the screen will look like.

 

 

This means, we have the salary available in the table ‘Salary table’.

 

Now go to Simulate function.

 

 

 

You have the result as follows.

 

 

These are nothing but the fields of my table ZSALARY. (The heading is coming like this since I kept the data elements of fields as standard char20 and all).

 

Now you are done with the creation of a simple BRF application.

 

I will explain on how to send a mail from this application and how to execute it from an ABAP program/BADI in the part 2 of this blog BRF Plus- A real time example – 2

 

Please let me know if you have any queries.

 

Thanks,

Faisal

Assigned Tags

      22 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Thanks for Nice writeUp.

      Author's profile photo Carsten Ziegler
      Carsten Ziegler

      Only found this blog today.

      Excellent work, thumbs up!

      ๐Ÿ™‚

      Author's profile photo Faisal PC
      Faisal PC
      Blog Post Author

      Hi Carsten,

      Thanks for the feedback.

      Thanks,

      Faisal

      Author's profile photo Former Member
      Former Member

      Hi Faisal,

      Great article.It would be great if you could also mention how to use the same or how the integration is done .

      Thanks,

      Saurav

      Author's profile photo el mekki ennoury
      el mekki ennoury

      Great post.

      Author's profile photo Faisal PC
      Faisal PC
      Blog Post Author

      Hi Saurav,

      How to use the BRF Plus application in code(reports/methods/BADIs etc) and running actions are mentioned in the next blog BRF Plus- A real time example - 2 . Please refer the same.

      Thanks,

      Faisal

      Author's profile photo Former Member
      Former Member

      Nice Article

      Author's profile photo Kumar Gaurav
      Kumar Gaurav

      Great work faisal...

      Thanks

      Kumar

      Author's profile photo Arijit Das
      Arijit Das

      Hi Faisal

      Great work on the blog! Well done!

      One question: how do you cater for a multi-line element in the Ruleset?

      If Data Object X is not initial; then change value of multi line element (derived via an expression)?

      The Expression works - it returns multiple lines. However it doesn't work with a Ruleset (in a Function). Any ideas on this?

      Thanks in advance

      Arijit

      Author's profile photo Former Member
      Former Member

      Hi Failsal,


      I am finding one issue. It is very strange issue with Database Lookup. While creating Database Lookup expression, I am expecting "With Condition" should allow me to provide condition but it is not giving me any option from where I can choose / create condition.


      Please see the below screen for reference. You can observe that I am not getting Graphical Access button itself to choose.


      Capture.PNG

      Author's profile photo Nagendra Babu Uppala
      Nagendra Babu Uppala

      Hi Faisal,

       

      Appreciate your effort, I have question. Whatever you have shown in this it can be done with Views also. What is the specialty of BRF + here?

       

      Author's profile photo Faisal PC
      Faisal PC
      Blog Post Author

      Hi Nagendra,

      You are right. All these things can be done via table entries as well. But SAP has given a standard framework where you have a lot of inbuilt options. You don't need to create multiple tables and make their relations. If you just explore BRF+, you will get to know that it's more than what we imagine. Lot of options are there which helps us in achieving the requirements and is less error prone.

      Thanks,

      Faisal

      Author's profile photo Former Member
      Former Member

      Hi Faisal,

       

      how do you create the rule Fetch Tier after If statement line 'If Tier is not initial'? : 'change Tier after processing Tier Table'? I could not find the right expression forย this.

      Author's profile photo Faisal PC
      Faisal PC
      Blog Post Author

       

      Hi,

       

      This picture has it.

      Thanks,

      Faisal

      Author's profile photo Reethimanth K
      Reethimanth K

      Hi Faisal,

      Thank you for writing this blog,

      Good work, easy to understand for beginners like me.

      I appreciate it.

      Here, I have one doubt, how to configure decision table with respect t0 the Condition Columns and Result Columns under Table settings.

      Regards,
      Reeth.

      Author's profile photo Sam Gemini
      Sam Gemini

      Very Nice ...keep it up.

       

      Author's profile photo Former Member
      Former Member

      thalaiva you are greaat

      Author's profile photo Former Member
      Former Member

      Excellent blog. Nicely explained... Need some more explanation on Rules with different inputs

      Author's profile photo Swapnil Mhadlekar
      Swapnil Mhadlekar

      Hi Faisal,

      I am getting following error while creating decision table.

      500 SAP Internal Server Error the assert condition was violated. (termination rabax_state) .

      what can be the Issue?

      Author's profile photo Faisal PC
      Faisal PC
      Blog Post Author

      This seems to be some Basis issue as 500 internal server error comes when the server is not reachable. However, could you please post the screenshot here?.

      Author's profile photo Abhilash KM
      Abhilash KM

      Very nice blog. Appreciate your work

      Author's profile photo Ramya. M
      Ramya. M

      Hi Faisal

      Your blog seems to be very much informative.

      Can you help me with this scenario, some discrepancy I have deleted a CATALOG from the brf+ application, I need to retrieve it as it has other rules and functions executing in the UI, will be great if you can share your views or workaround for this scenario.