You are on page 1of 6

Calling a BRFplus

function from an
ABAP program
Business Rule Framework plus ( BRFplus ), also known as Formula and Derivation Tool
( FDT ), aims to Make hard-coded rules in systems, process flows and services explicit and
easy to change for business professionals. Replace complex table-based determination by
an intuitive rule-based approach..
BRFplus is Business Rules Engine allows modelling and access rules. These rules consist of
building blocks such as decision tables, decision trees and formulas, its purpose is to allow
business professionals to change the rules quickly without the need of IT intervention ( ABAP
programmer ). This way the system becomes nimbler with rules than can be changed faster.
we build on the SAP tutorial Building a Tax Calculation Application to show how we can
implement the BRFplus function we already created from that tutorial.
Here is a sample code that could be used to consume our TAX_CALCULATOR BRFplus
function.

*---------------------------------------------------------------------*
* Report Z_BRFPLUS_TEST
*
*---------------------------------------------------------------------*
*
*
*---------------------------------------------------------------------*

REPORT z_brfplus_test.
PARAMETERS: p_salary TYPE 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.


FIELD-SYMBOLS:
TYPE if_fdt_types=>s_message.
DATA: ls_tax
ls_salary

TYPE if_fdt_types=>element_amount,
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( D4AE52BE7EF21ED284F8C146EFF7943E ).
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.
LOOP AT lo_message->mt_message ASSIGNING .
WRITE: -text.
ENDLOOP.
ENDTRY.
The BRFplus function GUID can be retrieved by going to transaction BRFplus in the
functions General TAB.

BRFplus function details


If we test our rule in the Business Rule Framework we get the following result.

Simulation framework

Context values ( BRFplus function input values )

BRFplus funtion similation steps and Result


Finally we can check that using our program yields the same result.

Program input

Program result

You might also like