Академический Документы
Профессиональный Документы
Культура Документы
Products Industries
Industries Services and Support
Services Support Training
Training Community
Community Developer
Developer
Partner
Partner About
About
Ask a Question Write a Blog Post Login
Ebrahim Hatem
November 10, 2016 8 minute read
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,
ight 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,
ight destination and the how many day will be the passenger stay.
Rule 1: if the age greater than or equal 18, ight destination is madrid and the days to stay there more than 5
days, then the passanger will get discount 20%.
Rule 2: if the age of the passanger between 2 and 17 ( greater or equal 2 and less than 18 ) the passanger will get
discount 30% where the distination and days stay will not be taken into consideration.
Rule 3: if the passanger age less than 2, then the passanger will get a discount 100%. He can get ticket free.
These Rules could be applied in ABAP or any programming langauge by using if statmemnts 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 gure.
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.
2. Create BRFplus function and the rules
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 rst thing we create the rule1. See above the rule 1.
Rule 1: if the age greater than or equal 18, ight 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, ight destination and the days stay ) to get the result.
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”
And days stay greater than 5 days,
Our rules depend on the age. So we can ass the age as precondition.
So we have to assign the age as precondition.
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 BRFplus function
lo_fuction ?= cl_fdt_factory=>if_fdt_factory~get_instance( )
>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( '50E549C2C40B1ED6A6
" 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
Ebrahim
Alert Moderator
Assigned tags
SLA implementation in SAP Solution Manager 7.1 using the BRFPLUS framework
By Former Member , Jun 06, 2017
6 Comments
Muhammad Zafarullah
Like (1)
Christian Lechner
thanks for sharing this information. Nevertheless, there are some points that have to be mentioned:
(1) It is best practice to leave the short text of BRFplus objects empty. Just use the Text eld as these allows a
more readable naming of your objects. You should also customize your UI accordingly that only the Long Texts
for your objects are shown.
(2) Your way of calling a BRFplus function is outdated and shall not be used anymore, as it can lead to
performance issues. The optimal way of how to call a BRFplus function is described
here;: https://blogs.sap.com/2015/10/18/brfplus-basics-how-to-call-a-function/
(3) Quite general, but please check the spelling and the typos in your blog, as it is currently quite hard to read
at several spots :-(.
Best regards,
Christian
Like (3)
Like (1)
Former Member
However, there is one point I do not get. You are talking about Decision Tables all the time, but when setting up
the rules you are not using the Expression Type “Decision Table” at all.
I think the rules 1, 2 and 3 described above can be replaced with one single decision table using AGE, DEST and
STAY as input columns and DISCOUNT as result column.
Best regards
Hannes
Like (1)
Thank you for your comment. I think when there are complex rules, these rules should be managed and at the
end one decision should be taken. Maybe I am wrong!
Best regards
Ebrahim
Like (0)
Former Member
Like (0)
Sitemap Newsletter