"Brfplus (Business Rule Framework Plus) Is A Business Rules Management System (BRMS) Offered by Sap Ag. Brfplus Is Part of The Sap Netweaver Abap
"Brfplus (Business Rule Framework Plus) Is A Business Rules Management System (BRMS) Offered by Sap Ag. Brfplus Is Part of The Sap Netweaver Abap
“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.
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.
I am clicking on ‘Create application’.
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.
Master Data-> objects which are local by default and cannot be transported.
Activate all the data elements. (I created an internal table also to hold the values from db table.).
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.
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.
Execute it.
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
This is a continuation of my first blog BRF Plus-A real time example
In my last blog I shown you on how to create a BRF Plus application and how to simulate the same. Here we will see how we can send the result of the BRF Plus
application as an email and how we can execute the same from CRM WebUI or from an ABAP reprot.
1) Creation of actions:
In the previous blog, we saw that the result of salary is put into the table called ‘Salary table’ after executing certain rules. Now if I want to send a mail with the result
to a recipient, that can be achieved with actions.
I give the name for action as send_email and save the action. We will get the following screen.
Here in recipients list, we can give the value from context parameter. For instance you are evaluating something for a BP and the result is to be sent to the email ID of
the BP. In that case you can create context parameter email and get the BP’s email id using a function and assign that email here in recipients.
In Subject, you can give the title and then can give the body of the mail. In order to bring the context parameters to the mail, you can give them like &1, &2, &3 etc.
After giving the parameter names, press on ‘Refresh message palceholders’ button and then you will see the option to assign the values from &, &2 etc.
Here you can assign the values and send the mail. Save the action and activate it.
We are done with sending of mails. Now we have to assign the action to the function.
Go to the rule set where you have created all other rules.
Choose the action we have created. Now the bottom side of rule set will look like this.
Simulate the application and see the result.
Keep in mind that, in simulation mode the actions won’t get executed. You should have a COMMIT for actions to get executed.
Now let’s see how can we bring this BRF Plus application to a program/BADI/event handler etc.
The first thing to be got is the id of the function which you can get from the ‘General’ tab.
Now write the following code (I am considering the example of a report).
START-OF-SELECTION.
TRY .
" Get BRFplus function
lo_fuction ?= cl_fdt_factory=>if_fdt_factory~get_instance( )->get_function( '2C44FD80B9EC1ED4A9F31B316E69AE7A' ).
Consider using CL_FDT_FUNCTION_PROCESS=>PROCESS for the execution of the rules. This will be much faster. A template for calling can be generated from
the menu on the function detail screen.