Вы находитесь на странице: 1из 54

Business Rule Framework

plus(BRFplus/BRF+)
Agenda
What are Business Rules ?
Conventional Methods
Business Rule Management
How it began
Releases
Features of BRFplus
Rules Creation Process
Execution Process
Sample Application
What are Business Rules ?
Conventional Methods
Business Rules Management & its benefits
Ubiquitous Business Rules
How it began ?
Started development project to investigate the usage business rules for the new technology under the code name Vienna - now its
BusinessByDesign
Importance of the business rules and the advantage of highly flexible and code-free customization began the development of a
general purpose BRMS what is known today as Business Rule Framework plus(BRFplus)
Working title of the BRFplus was Formula&Derivation Tool(FDT)
The following list contains the important tools and engines at that point in time:
Business Rules Framework (BRF)
Condition Technique
Costing Formula Builder
Derivation Tool (and clones)
Formula Builder (Fobu)
Hierarchical Derivation Service (HDS )
Internet Pricing and Configurator (IPC )
Rule Modeler
Validation, Substitutes, Rules (VSR)
Workflow Rules
BRF was developed for the insurance solution but it had its own restriction later BRFplus came into picture for more generic usage
with added capabilities.
BRFplus is integrated perfectly with the ABAP stack and supported ABAP-based applications in the best possible way.
It preserved the functionality of all the existing tools
Releases
BRFplus was first shipped in SAP Netweaver 7.0. This shipment included only few pieces of the infrastructure and had no
user interface. It served some pilot customers but was never intended to be used on a large scale. Since then, many
incompatible changes were introduced. Therefore highly discourage to use BRFplus in that release.
Next shipment was with SAP Netweaver 7.0 EHP1. The basic infrastructure could be completed and a UI was provided. But
still, there were quite some limitations, such as missing features, poor usability, and stability of some components. Simple
scenarios can be supported by this version, using functions, data objects and the expression types Decision Table, Formula,
and Case. For more complex scenarios, the recommendation is to use BRF and consider a migration to BRFplus as soon as
SAP NetWeaver 7.0 EHP2 is available.
Complete shipment was with SAP NetWeaver 7.0 EHP2 . It can be used for use cases of any degree of complexity. Based on
this release, the migration pilot projects have been completed and are shipped as part of SAP ERP 6.0 Enhancement Package
5.
The pilot projects are:
Tax and Revenue Management
Social Case Management
Social Application Processing
Social Service Plan Processing
Deduction Plan Processing

From this release on, the recommendation is not to use BRF for new projects anymore but to use BRFplus instead.
Features - BRFplus
Rules Authoring
Developed on Webdynpro ABAP technology
No installation is required as it runs on browser
Is embedded in the Application UIs(SAP SRM) or used standalone.
Fully support data dictionary.
Simulation tool allows the business users to test rules before releasing them.
Additional tools and views are available for the tracking of changes, consistency checks , dependency analysis, XML and MS Excel to
name a few.

Rules Engine
Specific rule entities can be accessed and processed with jus a few lines of ABAP code
Generated Webservices and RFC enabled function modules can be used for remote invocation
Incorporates code generation framework for best performance.
Concept of time travelling: Rules can be processed for a specific timestamp so that the definitions that were valid at the specific
point in time are applied.

Rules Repository
Rules can be stored client dependent or client independent as system, customizing and master/application data
Connected to SAP Change and Transport System(CTS)
Data exchange via XML export and import supported
Authorization concepts
Versioning to allow tracking of changes or time dependent rules processing.
Prerequisites
Role
SAP_BC_FDT_ADMINISTRATOR

WD Configuration
/sap/bc/webdynpro/sap/fdt_wd_workbench
/sap/bc/webdynpro/sap/fdt_wd_object_manager
/sap/bc/webdynpro/sap/fdt_wd_catalog_browser
Rules Creation Process
Terminology
Application - Container for all kinds of different BRFplus objects . All BRFplus objects are assigned to exactly one
application . It imposes some common technical settings such as development package, software component and
application component. The application component and software component have to be the same as defined for
the development package. The application and software component are automatically derived from the
development package if they are not set.
There are three types of applications Customizing application, Master Data application, and System
application. Customizing and System applications can be local, but Master Data application is always
local. All three types of application can be assigned to a development package. The type of application
can be set when a new application is created.

Data Objects - A data object behaves like a variable in a programming language . Data carrier in the context
or as storage for the result of an expression or action . Data objects can be of element type, structure
type or table type.

Expression Types - Defines a self-contained computational unit with a well-defined logic. BRFplus comes with
a set of common expression types and will be continuously enhanced by new expression types. You can
create your own expression types and use them in rules.
Types of Expression

Case The case expression is similar to the


ABAP CASE statement. The expression
takes a case parameter and checks its
value against a number of test
parameters.
Terminology
Constant The constant expression is the most simple expression. It
returns a fixed value that may be used by other expressions.
Random The random number expression provides two different
functionalities. On the one hand, the expression can be used to
return a random number between a minimum and a maximum
value. On the other hand, it can check whether a specified
probability between 0 and 1 is met and accordingly returns a
Boolean value.
Static Method Call The static method call expression calls a static method on an
ABAP class and implements a special interface.
Value Range Value range expressions check if the value of a test parameter
lies within a certain range. The result of a range expression is
always boolean. The expression returns the value as true or
false depending on whether the value falls within the defined
range.

BRMS Connector The BRMS connector enables one to use the SAP NetWeaver
BRM or any other external rules engine with BRFplus.
Decision Table The decision table expression sequentially processes rows of a
table that consists of condition and result columns. If all
conditions in a row are met, the corresponding result values
are returned. The decision table can work in two modes: single
match and multiple match modes.
In the single match mode, the decision table stops processing
at the first matching row, thus returning a single result.
In the multiple match mode, all rows are processed and the
results of all matching rows are collected into a table.
Formula The formula expression allows you to perform a wide range of
mathematical, boolean and other kind of calculations. It can
use any other expression or context data objects to determine
the result.
Function Call It allows to call the function. This makes the function
resuable.They may be a part of another application in that case
access levels to be considered.
Rule A rule consists of a condition and two actions, true action and
false action. If the result of the expression is true then the true
action is processed. If the result of the expression is false then
the false action is processed.
A rule checks a condition and fires an action depending on the
result. The condition can be a context data object or an
expression that provides a boolean result value.
XSL Transformation This expression performs an XSL transformation to determine a
result. A list of parameters (context data object or nested
expression) is passed to the XSL transformation as input. The
transformation can either be referenced by name (the
transformation has to exist in the system) or it can be derived
from a nested expression or context data object value.

Expressions access context data objects and may nest other expressions to calculate or determine a result. They are the
building blocks for rule and function as definitions.
Terminology
Actions - Actions are expressions of an action type .
Action Types - Action types are special expression types that define the interactive part of BRFplus . Action types do
not have any output. Instead, they define some result-independent processing, based on incoming data. Since
action types are highly application-dependent, BRFplus provides only a few generic ones.
Types of Action

Context Change The context change action sets the value of a


context data object at runtime. Expressions
and other context data objects can be used to
provide the value to be set.

Message Log The message log action is used to write


messages into an application log. Messages
are created from message class definitions in
the backend or by entering free text with
some parameters. The parameters of the
messages can be filled directly or may be
derived from context data objects or nested
expressions at runtime.

Static Method Call The static method call action takes a class
which implements a special interface and calls
a specific static method at runtime. To
determine a result, the method can access the
context and an optional set of (sub)
expressions.
Terminology

Ruleset - A ruleset handles the processing for a collection of rules. A rule in a ruleset can be enabled or disabled in
general. Its validity can also be restricted to a certain time period .
Execution Process
Sample Application
1. Set up a sample application, Function and Ruleset.
2. Derives the price of some product
3. Add shipping costs of 5%, but at least 2$, if the price
is under 100$.
4. Send a notification mail if a product is not found in
the price list.
5. Finally we test the application
1. Create an Application, Function, and
Ruleset - 1
Call the BRFplus Workbench
Call transaction BRFPLUS/BRF+
Click Workbench Personalize and select Show in Change Mode as Viewing Mode. Then click Save. By doing so, you do not need to
change to edit mode in every single screen

Call transaction BRFPLUS again for the changes to become effective (you can do so by refreshing the browser page). This will always
makes you to view in editable mode
1. Create an Application, Function, and
Ruleset - 2
Create a new Application
Click Workbench Create Application
Enter Name, Short Text, and Text, e.g. <your name> (you can use the same for all three fields, if the text is short enough).
Check Create Local Application.
Click Create and Navigate to Object.
Click Activate and confirm the popup window with Activate.
1. Create an Application, Function, and Ruleset - 3

Create a Function assigned to that Application


Right click on your just created application in the repository tree on the left side of the screen and select Create Function
Enter Name, Short Text, and Text, e.g. Product Price
Click Create and Navigate to Object
1. Create an Application, Function, and Ruleset - 4

Define the Signature of the Function


Select the Signature tab
Click Add New Data Object Add New Data Object
Enter Name, Short Text, and Text, e.g. Product
For Length select a reasonable
text length for product names, e.g. 40
1. Create an Application, Function, and Ruleset - 5

Click Create and Navigate to Object and confirm the popup window with Yes to save your input
Select tab Domain Values
Click Create Value
Enter Name, Short Text, Text, and Value, e.g. Tennis Racket and click Create
Repeat that previous step for some more
products
Click Back and confirm the popup
window with Yes to get back to your
function
1. Create an Application, Function, and Ruleset - 6

Ensure you are in the Function editor


At Result Data Object click on the icon right of the word Actions and select Create
Enter Name, Short Text, and Text, e.g. Price
Select Element Type Amount
Enter a reasonable number of digits for a price including the defaulted 10 decimal places, e.g. 15
Click Positive Values Only
Click Create
1.Create an Application, Function, and Ruleset - 7

Create a Ruleset assigned to the Function


Select tab Assigned Ruleset
Click Create Ruleset
Enter Name, Short Text, and Text, e.g. Product Price
Click Create and Navigate to Object and confirm the popup window with Yes
Click Enable Ruleset
Create an Application, Function, and Ruleset - 7

Click Save
You have now created the framework of your business rule. What is left is to create the actual rules themselves in the
following exercises
2. Define a Simple Rule

The decision table shall return the price for a specific


product
In case there are several entries for the same product,
the first one is taken into consideration
If no matching entry is available, an intial value is
returned
2. Define a Simple Rule - 1

Create a Rule using a Decision Table


Ensure you are in the Ruleset editor for the Ruleset you created
Click Insert Rule Create
Click Enable Rule
Enter a Description, e.g. Look up product prices
At the Then branch click Add Process Expression Create
Select type Decision Table
2. Define a Simple Rule - 2

Click Create and Navigate to Object and confirm the popup window with Yes
Click Return an initial value if no match is found
Click the icon right of Result Data Object and select PRICE (the name of the data element of type Amount that you created
earlier) and confirm the popup window with Yes
2. Define a Simple Rule - 3

Click Insert Column From Context Data Objects


Select PRODUCT (the name of the data element of type Text that you created in Exercise 1 above) and click Select
Click OK
2. Define a Simple Rule - 4

Click Insert New Row


Click on in the first column of that new row
Enter a product name in the empty field, e.g. Tennis Racket (you can select products you created before by clicking on the
icon right of it)
Click OK
2. Define a Simple Rule - 5

Click on in the second column of the same row


Enter a price and a currency, e.g. USD for US Dollars (you can select a valid currency by clicking on the icon right of the
currency field) and click OK. We are using US Dollars in this example. If you are going for another currency you need to
replace US Dollars with that currency at all later occurrences
2. Define a Simple Rule - 6

Repeat the last five steps (from Click Insert New Row) for several products. Also include at least one product more than
once with different prices
Note: you can set the Table Check Settings to not allow for duplicates. In this case we want to allow duplicates. So later we
can observe that only the first match is considered
Click Back and confirm the popup window with Yes (now the ruleset you created before should be selected)
2. Define a Simple Rule - 5

Click Enable Rule


Click Save
3.Define more Complex Rules

Add other Rules to the existing Ruleset using Formulas


and Actions (e.g. Sending an Email)
Derive the shipping costs (5%, but at least 2$, if the price
is under 100$, nothing if the price is 100$ or more) using
a Formula and add them to the price
If the product was not found in the price list (price is set
to initial value), trigger a notification mail to a fixed email
address
3.Define more Complex Rules - 1

Add other Rules to the existing Ruleset using Formulas and Actions
At the right side of the rule we already created click Other Operations Insert Next Rule by Create
Click Enable Rule
Enter a description, e.g. Add Shipping Costs
At the If branch click on No Condition Assigned. Assign Condition Use Value Range From PRICE
3.Define more Complex Rules - 2

Select condition is greater than


Enter the currency USD for US Dollars (you can select a valid currency by clicking on the icon right of the currency field).
The amount is 0, which is prefilled anyway
3.Define more Complex Rules - 3

At the Then branch click Add Process Expression Create


Select type Formula
Enter Name, Short Text, and Text, e.g. Add Shipping Costs
Click Create and Navigate to Object and confirm the popup window with Yes
Click on the icon right of Result Data Object and select PRICE (resp. the name of the result data object you created in
exercise 1). Maybe you need to click Search before the PRICE object is being displayed
3.Define more Complex Rules - 4

By using context elements, operators, and formula functions offered at the lower part of the screen enter the formula
PRICE + IF ( PRICE >= 100_USD , 0_USD , MAX ( 2_USD , PRICE * 0.05 ) )

Click the Check button to make sure that the formula is syntactically correct
Click Back and confirm the popup window with Yes
3.Define more Complex Rules - 5

Click on the pencil icon (Edit Rule) at the second rule

At the Else branch click Add Perform Action Create


3.Define more Complex Rules - 6

Select type Send Email (Act)


Enter Name, Short Text, and Text, e.g. Notification Mail
Click Create and Navigate to Object and confirm the popup window with Yes
3.Define more Complex Rules - 7

At the Recipient(s) field enter an arbitrary email address (we are not going to actually send the mail. So it does not matter,
whether the address is valid or not)
3.Define more Complex Rules - 8

Enter some Subject, e.g. Notification: Product not available


Enter the body text, where you replace the product name by &1, e.g. The product &1 does not exist. Regards, your Sales
Team
Click Refresh Place Holders
Click on the icon right of Variable 1 and select PRODUCT .
Click Save
4.Run the Rules

Activate all created objects


Run Function in Simulation Mode
4.Run the Rules

Activate all created objects


In the repository tree on the left select the Ruleset you created before
Click Activate and confirm the popup window with OK
4.Run the Rules - 2

On the upper left of the screen you should see a success message Object(s) activated and all objects you created should
show a green icon in the repository tree, indicating they are active
If there still are inactive objects, select them in the repository tree and click Activate

Run Function in Simulation Mode


In the repository tree on the left select the Function you created before
Click Start Simulation
4.Run the Rules - 3

Click Show also Results of Intermediate Steps (radio button at the bottom of the screen)
Enter a product (you can select products you created before by clicking on the icon right of the input field)
Click Run Simulation
4.Run the Rules - 4

Notice the resulting price at the top of the screen


Notice the intermediate rules processing steps
-Looking up the price in the decision table
-If a product does not exist, the price is set to
the initial value zero
- If a product is listed more often than once, the price
of the first occurrence is returned
- Adding shipping costs if the price is not zero
- Triggering a notification mail otherwise
5.Call the Application
5.Call the Application - 1
Summary

Вам также может понравиться