Vous êtes sur la page 1sur 20

BRF+

What is BRF+ ?

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.
It allows you to build complex business rules and then consume the rules
from any application.

2015 IBM Corporation

Key Trends and Issues Driving Change in Application Development

2015 IBM Corporation

Challenges

2015 IBM Corporation

Evolution of Business Application Architecture

2015 IBM Corporation

Business Applications, Business Processes, and Business Rules

2015 IBM Corporation

Benefits of Using Business Rules Management

2015 IBM Corporation

BRFplus can do Much Better Than Other Rules Engines

2015 IBM Corporation

A Brief POC Implementation Approach


A purchase order can be
created using transaction
code ME21N. By default
the Tax Code field (see the
highlighted field below) has
to be set manually. Some
countries such as Brazil
have very complex tax
laws and consequently the
tax codes are frequently
not set correctly and
setting it correctly takes
considerable time that
should be spent in more
value adding activities.

2015 IBM Corporation

Implementation Approach
Definition of Task
First clarify the task to be accomplished with the decision service. Perfect candidates are tasks
that are free from side effects, this means you have a set of attributes and based on the values of
those attributes you want to derive or calculate the values of one or several other attributes. Often
tasks are related to one of the following:
Validations
Derivations
Defaulting
Classification
Calculation
Mapping
Boolean decisions
Typically these are micro decisions. Micro decisions occur very frequently but the impact of a
particular decision is not big compared with decisions that affect the complete enterprise such as
strategic decisions about starting a new product line. However, micro decisions tend to occur very
frequently and to be well-structured. Cumulatively they can have a big impact on the financial
result of a company as they directly impact the efficiency of the operations.
In the example of this document the decision service is called for every purchase made. Incorrect
tax codes require the purchase order to be reworked, which is a significant cost factor for
organizations burdened by complex tax laws where purchasers frequently have difficulty
determining the correct tax code.

2015 IBM Corporation

Decision Service Definition


Knowing the task we can start to define the decision service:
Name Set Tax Code
Description Set the Tax Code in the Purchase Order Creation process
This definition is not yet complete. We also need to define inputs (the context for the decision rules) and outputs (the
results) of the service. Usually business people can derive that from the rules they have in mind. It is not a problem if
this list is not complete upfront as more parameters can be easily added at a later point in time. Ideally, the equivalent
Data Dictionary data elements (shown in brackets in the example below) are already known so that technical
attributes as well as business semantics can be derived from the dictionary.
Inputs/Context
o Company Code (BUKRS)
o Plant (EWERK)
o CFOP Category (J_1BINDUS3)
o Material Usage (J_1BMATUSE)
o Material Group (MATKL)
Outputs/Results
o Tax Code (MWSKZ)
Parameters are not always elementary (i.e. single value). This is why BRFplus also supports structure parameters,
table parameters, and even deeply nested complex types (e.g. a structure with a component being a table).
The service definition is shown in the next screenshot. In BRFplus a service is implemented with the help of a
BRFplus Function. The Signature tab contains the context, which provides the inputs for the service call. It also
contains a Result Data Object, the tax code. The following screenshot shows the function in the BRFplus workbench
(transaction code BRF+).
10

2015 IBM Corporation

11

2015 IBM Corporation

Data objects are used in BRFplus


to define parameters. The
parameter Material Group, for
example, is defined by a data
object shown in the next
screenshot. This can be reached
by selecting the hyperlink on
MATKL in the Signature tab. You
can see that properties such as
texts, element type (text), and
length are taken over from the data
element MATKL which is defined in
the data dictionary. BRFplus is also
able to find possible values in
domain lists or check tables so that
a value help based on those values
can be provided when modeling
rules.

12

2015 IBM Corporation

Decision Service Trigger


Implementation
After having created and activated
the data objects and functions, the
new decision service is ready to be
plugged into the right place in the
process. Often you can find BADIs,
enhancement spots or other exit
options for exactly that purpose.
For the setting of tax codes BADI
ME_PROCESS_PO_CUST provides
exactly what is needed in method
PROCESS_ITEM. The screenshot
below shows the BADI
implementation in transaction SE19.

13

2015 IBM Corporation

The call of the decision service happens in the implementing class ZCL_IM_ME_PROCESS_CUST in method
IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM.
METHOD if_ex_me_process_po_cust~process_item.
DATA: ls_item TYPE mepoitem, ls_header TYPE mepoheader, lv_tax_code TYPE mwskz, lo_function TYPE REF
TO if_fdt_function, lo_context TYPE REF TO if_fdt_context, lo_result TYPE REF TO if_fdt_result, lx_fdt TYPE
REF TO cx_fdt.
ls_item = im_item->get_data( ). ls_header = im_item->get_header( )->get_data( ).
CL_FDT_FUNCTION_PROCESS=>PROCESS( ) for better performance lo_function ?=
cl_fdt_factory=>if_fdt_factory~get_instance( )->get_function( 'FE69C64EA2DB3811E10000000A428A79' ). TRY.
lo_context = lo_function->get_process_context( ). * NOTE: consider using IDs instead of names (IDs do never
change but names may) lo_context->set_value( iv_name = 'BUKRS' ia_value = ls_header-bukrs ). lo_context>set_value( iv_name = 'MATKL' ia_value = ls_item-matkl ). lo_context->set_value( iv_name = 'EWERK' ia_value =
ls_item-werks ). lo_context->set_value( iv_name = 'J_1BINDUS3' ia_value = ls_item-j_1bindust ). lo_context>set_value( iv_name = 'J_1BMATUSE' ia_value = ls_item-j_1bmatuse ). lo_function->process( EXPORTING
io_context = lo_context IMPORTING eo_result = lo_result ). lo_result->get_value( IMPORTING ea_value =
lv_tax_code ). CATCH cx_fdt INTO lx_fdt. * TODO: error handling, take error message text from lx_fdt>mt_message ENDTRY.
ls_item-mwskz = lv_tax_code. im_item->set_data( im_data = ls_item ). ENDMETHOD.
In the code first the item and header data is retrieved from the user interface. Then an instance of the BRFplus
function is created. Note that the ID can be found in the BRFplus. The next step in the code is passing the
parameters. Then the function is processed, meaning the decision service is called, and the result is copied back
to the tax code field of the item data structure.
There are also other ways of invoking a rules service. Some of them guarantee better performance. But this
instance-based approach is easier to read.

14

2015 IBM Corporation

Decision Service
Implementation
The service is defined and
plugged in to the right
place in the process, but
there no business logic has
been defined so far.
Business logic can be
implemented in Rulesets in
BRFplus. One or more
rulesets can be created
from the function screen.
Rulesets can have preconditions and priorities to
define the order of
execution. In the tax code
example there are two
rulesets. One is valid for all
cases where the company
code is 0001 and the other
one is valid for all other
cases.

15

2015 IBM Corporation

The first ruleset (below)


is self-explanatory. For
demonstration purposes
the ruleset has been
deliberately defined in
this simple way.

16

2015 IBM Corporation

Decision Service Testing


A decision service can be tested
directly in the BRFplus workbench on
the Function user interface with the
button Start Simulation. On the
simulation screen values can be
entered or loaded from excel.

17

2015 IBM Corporation

When using the option


Execute and Display
Processing Steps the
simulation output will be very
detailed showing context,
processing steps and result(s)
in a well-organized execution
hierarchy tree, which also can
be downloaded into Microsoft
Excel.

18

2015 IBM Corporation

So the Set Tax Code


task is now solved with
help of a decision
service implemented in
BRFplus. With an effort
of just a few hours
BRFplus can be used
to implement a decision
service to cater for
automation of many
tasks, freeing up time
for more value adding
work. The business
rules that implement
the decision service
can be understood and
even be changed by
the domain expert so
that the IT professional
does not need to
understand the
business details.

19

2015 IBM Corporation

Thank You

20

2015 IBM Corporation

Vous aimerez peut-être aussi