In my recent project, I got a chance to work on BRF Plus and I found the benefits of BRF Plus very interesting. Generally when we talk about an application we always talk in terms on UI and backend logic. Interestingly if we look little closer, we can divide the backend logic as business processes and rules.
For instance creating a SO from lead is a business process and it remains the same for all entities, but what gets changed is the discount calculation for different buyers. The way the discounts are calculated becomes the part of business rules. Separating rules and processes helps in keeping the application stable. Here is where BRF plus helps us maintaining this segregation.
All the rules required by the application can be maintained in BRF Plus and it can be consumed in the application process where it is required.
Changes in the rules will not affect the application and hence keeping it more stable.
To open BRF Plus workbench use the transaction FDT_WORKBENCH in SAP CRM system. You can create your own application by clicking on ‘Create Application’.
While creating an application, it is important to maintain certain fields correctly based on your requirement:
To create a simple rule which can be exposed as a RFC function module or web service, select ‘Function’ in the ‘contained’ objects’ tab and create the object. The function can be defined in three modes –
1). Event Mode: The rule set are defined and executed to give the final output.
2). Functional mode: A top expression of any kind is executed and the final output is provided.
3). Event and Functional mode: After top expression is executed, the rule sets are also executed.
The function will contain importing and exporting parameters same as ABAP function. The importing parameter is called as context variable and exporting parameter is called as result set.
The context and result set can be defined with new data objects or existing data objects from DB can also be used.
The BRF Plus function can be generated as an ABAP classes. When the function is tested via simulation mode, it can be selected whether to run the function in generated mode or interpretation mode. In generation mode, the ABAP class will be executed. In interpretation mode, the rule set will be interpreted and then executed.
The rules in the function should be defined as rules set. Rule set are collection of rules. Rules can be defined with an expression type. Rules are always executed within a rule set, it cannot be executed independently. Predefined expression type is available and also customer can create their own expression types. Predefined expression types are available like
A simple rule can be like:
If<condition>
<action>
Else
<action>
For a complex calculation, different features of BRF Plus like looping over table, appending values to a table and complex expression types can be used.
Different kinds of action are also possible which are executed based on the rules defined.
BRF Plus supports the following action types:
Advanced tools are available in the BRF Plus which is available only in expert mode. To change the user mode, select the personalize button in the right hand side and select expert as the mode. Various new options are shown in the Tools menu as an expert user. A BRF Plus function can be exposed as RFC FM or web service in the expert mode. The web service or RFC FM can be called from any application like java or SAP application. To call the BRF plus FM directly from ABAP code, the function ID is used. Function ID is visibility in ‘general’ block of the function in BRF Plus workbench. A context reference is defined and using that the function can be called.
PARAMETERS: p_salary TYPE SNWD_SALARY_AMOUNT.
DATA: lo_fuction TYPE REF TO if_fdt_function,
lo_context TYPE REF TO if_fdt_context,
lo_result TYPE REF TO if_fdt_result.
DATA: lo_message TYPE REF TO cx_fdt.
DATA: ls_tax TYPE if_fdt_types=>element_amount,
ls_salary TYPE if_fdt_types=>element_amount.
START-OF-SELECTION.
CLEAR: ls_tax.
ls_salary-number = p_salary.
ls_salary-currency = 'EUR'.
TRY .
" Get BRFplus function
lo_fuction ?= cl_fdt_factory=>if_fdt_factory~get_instance( )->get_function( '005056934CFD1EE3A7BF28BC1C865C25' ).
" Set the BRFplus function context ( input variables )
lo_context = lo_fuction->get_process_context( ).
lo_context->set_value( iv_name = 'GROSS_SALARY' ia_value = ls_salary ).
" Process the BRFplus function
lo_fuction->process( EXPORTING io_context = lo_context
IMPORTING eo_result = lo_result ).
" Retrieve the BRFplus function result
lo_result->get_value( IMPORTING ea_value = ls_tax ).
WRITE ls_tax-number.
WRITE ls_tax-currency.
CATCH cx_fdt INTO lo_message.
ENDTRY.
Interesting feature of BRF Plus:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
1 | |
1 | |
1 |