Expand your toolbox – how BRFplus and DSM help you get rid of custom code, and help you manage complex rules (part 1 of 2)
Why you should know about BRFplus and DSM?
It looks like a good fit for a number of industry-specific challenges in our industry – from defining products, to modeling manufacturing constraints, or make manufacturing processes more reactive to deviations. Besides that – it’s the standard tool SAP uses internally for a number of similar use cases.
Finally, it may be a key component to get rid of, or at least simplify custom code.
Some may call it serendipity or coincidence when similar solutions are found in multiple places. But maybe it is just that a new tool is applied more broadly and with more creativity. It may have also helped that BRFplus became a defacto standard of the Business Suite:
I first came across BRFplus ( SAP’s business rules framework plus) and DSM (SAP Decision Service Management, a powerful add-on to BRFplus) through an inventive Austrian customer, and the idea spread fast, and was re-invented independently by multiple SAP consultants in other locations and industries: to use BRFplus as an extension of VC (variant configuration)..
Are rules engines a new tool in our industry?
In metals, especially in steel, rules engines have been in use since years for order dressing: to calculate from the sales order specification one, or multiple, feasible options to manufacture this specific customer requirement. There are a tens of thousands of possible “paths” a steel coil could theoretically take through an integrated steel mill – but for a given specification there may only be 3 – 5 optimal ways to achieve the required quality at best profitability. But a number of constraints define what is feasible e.g. certain rolling mills can only handle certain widths or thickness for a specific grade.
To define these constraints, and to calculate the feasible path through the mill, in many cases rules engines were built as in-house developments– in larger customers we have found even multiple different handcrafted rules engines within one company.
In other mill companies, the rules knowledge may only be in the heads of the manufacturing experts and engineers of the company – which is a risk as those experts may retire (with their experience). Again another mill company had their knowledge to create recipes for dyeing yarn or fabric captured in 5 heavy volumes – their “color bible”. Finally there are a number of hardcoded Ifs and THENs in many BADIs, Customer Exits or Enhancement Spots at every customer I have met so far.
All these could possibly be replaced with BRFplus.
How new or proven is this BRFplus and where’s the benefit for you?
BRFplus is broadly adopted in many business suite applications already – from commodity management, transportation to quality issue management. So your business users will anyhow work use it more broadly in standard use cases.
BRFplus claims to be simple enough that business users can create and update rules. (We will come to my first-hand test in a minute)
BRFplus is part of NetWeaver and thus already in the NetWeaver stack of your suite applications. So you do not need to install and manage another system.
BRFplus has the option to reduce & simplify your custom code, and your VC model – as it separates program logic from decision logic.
Self-Experiment: How difficult it is to define rules in BRFplus?
Seen the slides, heard the pitch – now I wanted to try it first hand: Does BRFplus hold the promise? Is it simple enough so that I can create rules without proper training?
a) Create a simple input verification whether an entered length for a tube product can be manufactured (through a simple look-up table).
b) Create a complete set of rules that can calculate the net weight and the coated surface area of various typical mill products (sheet, plate, bar, tube)
The BRFplus book (written by Carsten Ziegler) and a sandbox ECC system.
Stefan’s solution approach – Use BRFplus with decision tables and formulas
Challenge a) Simple Input Verification – Step by step description (elegance of modeling: low beginner level – experts, beware!)
- Created local application “SW_Demo_Overview”.
- Created BRFplus function “SW_Demo_Function”.
(ABAP coders think- ABAP function module interface aka BRFplus function signature)
In this first example, I just import the product name and the length the customer has entered (e.g. through a variant configuration characteristic). As a result I return whether the length is in the allowed range, or not: Boolean result parameter L_OK.
The function is what you would call from a BAdI, or any ABAP code – like in a VC procedure ABAP function call. Check out the push button “Create code template”. Very convenient.
- Assigned & created a new ruleset “Validate Length Ranges” to the above function
The ruleset defines the sequence the rules are called.
It also enhances the context – basically the set of parameters & variables you use during calculations – handed over from one rule to the next. I have defined a upper and lower allowed length L_MAX and L_MIN.
I also defined an Initialization logic (sounds amazing, but is rather underwhelming). Basically – when the ruleset is called – I look-up the upper and lower length in a decision table and store in the 2 global variables.
- Defined a simple decision table and filled the content through Excel upload.
The table is rather simple – 3 columns: the product and allowed length interval.
- You could easily change table cell values manually, or download and re-upload via Excel. Works nicely, but take care that you don’t mistype in Excel. BRFplus will complain during upload if you your values match the required format.
- Created and assigned one rule “Check Length Interval” to the above rule set.
Rules are the “atoms” of BRFplus – they are grouped in rule-sets which define in which sequence the rules are executed. For example a) I only created one rule.
- The structure of rules is nice and intuitive. IF condition – THEN do something– ELSE do something else. My rule is a little less intuitive, but I hope it’s understandable: .
First, in the IF-section, I use a formula expression to check whether the entered length is in the range defined by previously determined L_MIN and L_MAX.
If this is the case, all is fine and nothing is executed in the THEN section.
If not, the ELSE section is executed and the operation “length range error” is “fired”.
- Created formula LENGTH_CHECK. Here I have to correct what I said above. The atoms of BRFplus are the expressions (that you use in formulas). You have already seen the decision table, the formula is another powerful expression type. The formula allows you to create straightforward calculations. I will make use of this in part b). And you can create a logical expression, like I did here. If you do not get the “syntax immediately, select e.g. the IF in the formula, and you will get more information how to use the syntax element. Sorry, Carsten, I did not even need to open your book.
- Last step was to activate the whole enchilada, and test it.
Conclusion and Curiosity
Once I understood a few basic concepts (like variables and context) in BRFplus, it was straightforward to create the set of calculations rules and look-up tables. It was significantly easier than writing VC syntax. With the decision tables, it is rather easy and convenient to expand and adapt the model compared to pure ABAP.
In my opinion BRFplus – the SAP rule engine for the ABAP world – is an option to consider. Not only in the context of order dressing or VC, but in many places where you struggle with custom code.
Where’s the curiosity? Well, I wonder how easy it will be to do the more complex calculations.
Call to action
Get the book, try out the pricing example, or just type BRF+ in your sandbox – and start creating own rules.
To be continued
I will continue with example b) – geometrical calculations to determine the net weight- in my next blog.