BRF+ Business Use Case
Today I will talk about an application that is fully integrated with the SAP ECC system BRFplus (Business Rules Framework +). In this article, I will provide an application of BRF+ on a business case from one of my former clients.
BRF+ allows for rules to be modeled in an intuitive way that gives greater flexibility and visibility to the Business users who are not developers with training in ABAP. It is like giving more technical power to the Business users.
Please Note: In order to use BRF+ with your SAP ECC system, your system must be on SAP NetWeaver 7.02 SP6 or above.
T-Code is BRF+ or BRFplus
In your SAP ECC session input either of the above transaction codes, and you will be able to access BRF+ workbench. In the workbench, you will be able to create all objects needed for BRF.
Business Case – Material extension for new materials
There is an existing custom batch program which extends all materials to all storage type. However, not all materials require all storage types. The ABAP logic to account for the custom business rules required to extend the material to the appropriate storage type is complex and difficult to change when each new material attributes are introduced as part of the extension criteria.
BRF+ can manage the business rules in a decision table where it is scalable and transparent to the business analyst making updates per business needs.
This is where all of the components related to your application resides. i.e. Components: (Data Elements, Functions, Rulesets, Expressions, etc)
A) Define Data Elements: In BRFplus, the functional analyst creating the BRFplus function can create new data elements not included in the SAP ECC system or Bind your data elements to be used in the BRFplus function through the DDIC element (Data Dictionary) from SAP. In this business scenario, I will be using data elements from the DDIC.
General Item Category Group
Hazardous Material Number
B) Define Decision Table: The decision table is one of the most useful features in BRFplus. It allows for the business rules to be maintained in a table where the business user can easily import and export via excel when changes are required due to business needs.
TechName: DT_STORCLS_STORTYP DescName: STRTYP by STRCLS storage type (Output) by storage class (Input)
C) Define Structure and Tables: Structures need to be created to storage BRF+ function process results for further processing. Tables need to be defined when there are one-to-many (input to output) relationships.
i.e. In this business scenario, there exist multiple storage classes that have multiple types and vice versa.
D) Define Ruleset: A ruleset is a series of logic executed everytime the BRF+ function is called. In each ruleset, each rule can be configured with a validity period. This gives the business analyst (power user) a way to expire rules without having to go through an entire development lifecycle as with traditional ABAP development. Also, if the rule is required again at a later time, then the business analyst (power user) could implement the changes to mean business demands in a timely fashion. I will not be covering this feature in this article based on the focus of this article.
i.e. In this business scenario, we have 2 rules which are executed in a sequence within the ruleset.
Rule 1: For any material where the general item category is not blank with the exception of general item categories between ZBN2 to ZBN6, update the results structure with storage types after processing the 1st decision table in the figure below (Storage Type by Item category).
Rule 2: If the material is a hazardous material (indicated by the hazardous material is not initial or in ABAP STOFF IS NOT INITIAL.), update the results structure with storage types after processing the 2nd decision table in the figure below (Storage Type by storage class).
E) Define Function: The function is where the ruleset houses the sequence of rules executed. This is the BRF+ function that an ABAP application would call to retrieve results. The character string in the ID field is the BRF+ function ID the ABAP program will call on.
F) Connect BRF+ function to ECC ABAP backend: See ABAP Report Below
ABAPer would be interested in the below code. 🙂
TYPES: BEGIN OF ty_result,
sto_type TYPE string,
END OF ty_result.
PARAMETERS: p_gicgrp TYPE string,
p_lagkl TYPE string,
p_stoff TYPE string.
DATA: "lo_admin_data TYPE REF TO if_fdt_admin_data,
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_genitmcgrp TYPE if_fdt_types=>element_text,
ls_lvs_lagkl TYPE if_fdt_types=>element_text,
ls_stoff TYPE if_fdt_types=>element_text,
result_ref TYPE REF TO data,
it_result TYPE TABLE OF ty_result,
wa_result TYPE ty_result.
FIELD-SYMBOLS: <d_ref> TYPE ANY TABLE,
<ls_message> TYPE if_fdt_types=>s_message.
" Setting default selection values
if p_gicgrp IS INITIAL.
ls_genitmcgrp = 'ZNOR'.
ls_genitmcgrp = p_gicgrp.
if p_lagkl IS INITIAL.
ls_lvs_lagkl = 'AERO'.
ls_lvs_lagkl = p_lagkl.
if p_stoff IS INITIAL.
ls_stoff = 'X'.
ls_stoff = p_stoff.
" Get BRFplus function using the function ID from FT_MATNR_EXTENSION
" from BRF+ frontend
lo_function = cl_fdt_factory=>if_fdt_factory~get_instance(
)->get_function( iv_id = '005056A54A7C1EE5A2B06E9B9926520A' ).
" Set the BRFplus function context ( input variables )
lo_context = lo_function->get_process_context( ).
lo_context->set_value( iv_name = 'GENITMCGRP'
ia_value = ls_genitmcgrp ).
lo_context->set_value( iv_name = 'LVS_LAGKL'
ia_value = ls_lvs_lagkl ).
lo_context->set_value( iv_name = 'STOFF'
ia_value = ls_stoff ).
" Process the BRFplus function
lo_function->process( EXPORTING io_context = lo_context
IMPORTING eo_result = lo_result ).
"bind to our structure
CREATE DATA result_ref TYPE STANDARD TABLE OF ty_result.
lo_result->get_value( IMPORTING er_value = result_ref ).
ASSIGN result_ref->* TO <d_ref>.
LOOP AT <d_ref> INTO wa_result.
append wa_result to it_result.
SORT it_result by sto_type.
DELETE ADJACENT DUPLICATES FROM it_result.
write / .
write 'After de-dupe'.
LOOP AT it_result INTO wa_result.
CATCH cx_fdt INTO lx_fdt. "lo_message.
LOOP AT lx_fdt->mt_message ASSIGNING <ls_message>.
Note: In the event, duplicates occur, we may need to remove the duplicated values in the table
- The duplicate removal can be implemented by a simple ABAP function using SORT and DELETE ADJACENT DUPLICATES
- Using generic types for the method parameters makes for efficient procedure calls from BRF+
Also Check: How to Debug any Work Item in SAP Workflow?
Example of BRF+ function for material extension execution:
Based on Decision table entries:
Summary of series of events in creating a BRF+ function for ABAP Applications
This is what all working in BRF need to know and follow.
- Find/Create a new application folder in your BRF+ workbench
- Identify/Define Data Elements
- Create Decision Table(s)
- Assign Data Elements to Decision Table(s)
- Create Structures and Tables for Processing as needed
- If Structures and Tables are created, then assign the appropriate data elements to them respectively
- Create ruleset for function process
- Create rules within the ruleset
- Assign Tables, Structures, and Decision Tables for each rule processed as appropriate
- Create BRF+ Function
- Assign Ruleset to BRF+ Function
- Create ABAP program to call BRF+ Function
Hope, I have not overwhelmed you with too much information. My idea was to share a real project case where we implemented the Business Framework Rule. When there are exceptions in the normal process, instead of handling it in complex ABAP program, it is a better idea to make use of Rule Sets and Function in BRF+.
If you need any other information regarding BRF+, please feel free to leave it in the comment section below. We would be happy to revert.
Please browse our page for Fiori, SAPUI5, OData, HANA-ABAP, OOPs, Workflow, Web Dynpro etc tutorials.
Now we want to hear from you.
Have you used BRF+? Would you like to share your experience?
Please leave some quick comments below.