Académique Documents
Professionnel Documents
Culture Documents
What is BRF+ ?
Challenges
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.
11
12
13
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
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
16
17
18
19
Thank You
20