Professional Documents
Culture Documents
BRF+ in Hana-Blog
BRF+ in Hana-Blog
I just want to explain about this rule with an example. Every one has won rule or plan, or game. Anything
wich a condition we can call it as rule. There are many rules in our life, which could be divided into 3 parts
as I know, simple, medium or complex.
SAP provides business rules framework to manage the business rules. BRF consists of UI, rules repository
and a rules engine.
To express a rule we can use Decision Tables or Decision Trees. In this example, I will try to explain the
decision Table and how to do it in SAP by using sap transaction “BRF+” or “BRFPLUS”.
I would like to put simple rules for travel agency to buy ticket with some rules depends on three
conditions age, flight destination and the how many day will be the passenger stay.
I just want to explain about this rule with an example. Every one has won rule or plan, or game. Anything
wich a condition we can call it as rule. There are many rules in our life, which could be divided into 3 parts
as I know, simple, medium or complex.
SAP provides business rules framework to manage the business rules. BRF consists of UI, rules repository
and a rules engine.
To express a rule we can use Decision Tables or Decision Trees. In this example, I will try to explain the
decision Table and how to do it in SAP by using sap transaction “BRF+” or “BRFPLUS”.
I would like to put simple rules for travel agency to buy ticket with some rules depends on three
conditions age, flight destination and the how many day will be the passenger stay.
Rule 1: if the age greater than or equal 18, flight destination is madrid and the days to stay there more
than 5 days, then the passenger will get discount 20%.
Rule 2: if the age of the passenger between 2 and 17 ( greater or equal 2 and less than 18 ) the passenger
will get discount 30% where the destination and days stay will not be taken into consideration.
Rule 3: if the passenger age less than 2, then the passenger will get a discount 100%. He can get ticket
free.
These Rules could be applied in ABAP or any programming language by using if statements or switch case
and you can do what you want. But to avoid programming we can use SAP customizing tables and ABAP
code to make it easy and understandable for Business Analyzer and the programmer.
Then you can just create the application as shown in this figure.
Enter the application name and short text about it.
Development package you can use TMP if you don’t want to transport it, otherwise you will asked to
choose the transport number. In our example we don’t need to transport these rules to another system,
just as local as an example.
In this step, we can create our elements like age, flight destination and days stay as well as to the result
discount. In this example we have many elements, so we can choose add multiple elements.
These elements could be text or number, so we can choose the element type.
Our result consists of one element which is discount, it could as structure or table.
So we can create the discount as result of the our rules.
After that we can create our rules and try to save the changes.
We can now switch to the tab “Assigned Rulesets” to create the rules.
To create a rules, just under the insert rules, click on the create …..>
So the first thing we create the rule1. See above the rule 1.
Rule 1: if the age greater than or equal 18, flight destination is madrid and the days to stay there more
than 5 days, then the passanger will get discount 20%.
We have in this rule 1, three variables ( age, flight destination and the days stay ) to get the result.
We will add the flight destination,
We have many variables, so we have to add more condition, like this example
if A = … and B = … then …
else.
In this rule we can set the destination” Madrid”
Our rules depend on the age. So we can ass the age as precondition.
So we have to assign the age as precondition.
In this rule 1, the age must be equal or greater than 18.
Rule 2: if the age of the passenger between 2 and 17 ( greater or equal 2 and less than 18 ) the passenger
will get discount 30% where the destination and days stay will not be taken into consideration.
Rule 3: if the passenger age less than 2, then the passenger will get a discount 100%. He can get ticket
free.
After creating all the rules, don’t forget to save and active them.
Now our rules have been created and they are ready to use them in ABAP.
To use these rules in ABAP, we have to use the this three operations.
>get_function( ’50E549C2C40B1ED6A69FCB34B9365358′ ).
Try this simple program but don’t forget to change the function ID.
REPORT zibo_pg_decision_table1.
" the parameters
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t001..
PARAMETERS:
p_age TYPE age DEFAULT '20',
p_fl_des TYPE zibo_de_flugziel DEFAULT 'Madrid',
p_stay TYPE zibo_de_aufenthalt DEFAULT '6'.
INITIALIZATION.
t001 = 'Selection Criteria'.
START-OF-SELECTION.
PERFORM execute_rules.
PERFORM print_descision.
FORM execute_rules.
TRY .
" Get BRFplus function
lo_fuction ?= cl_fdt_factory=>if_fdt_factory~get_instance( )->get_function(
'50E549C2C40B1ED6A69FCB34B9365358' ).
" Set the BRFplus function context ( input variables )
lo_context = lo_fuction->get_process_context( ).
lo_context->set_value( : iv_name = 'AGE' ia_value = p_age ),
iv_name = 'FLIGHT_DES' ia_value = p_fl_des ),
iv_name = 'STAY' ia_value = p_stay ) .
ENDFORM.
FORM print_descision.
write:'Age :', (20) p_age.
write:/'Flight desstination :',(80) p_fl_des.
write:/'Days of stay :', (80)p_stay.
ULINE.
ENDFORM.
You can try all the possibilities and you will get the result ( Discount % ) as has done in decision table.
Regards