Skip to Content

This blog shows some best practices for the authoring of decision services in SAP NetWeaver Decision Service Management with BRFplus business rules. Where appropriate, I will contrast good with bad examples to illustrate my arguments. The idea of decision services based on business rules has the functional experts in its focus. These people need to be able to understand the business rules and take ownership of the logic that contributes to their success.

The screenshots were taken from a system with NetWeaver 7.3 Enhancement Package 1 (which is equal to NetWeaver 7.0 Enhancement Package 1) and SAP NetWeaver Decision Service Management 1.0.

Content

  • Descriptive object texts
  • Object documentation
  • Expression result values
  • Usage of technical expressions
  • Rule catalogs
  • Access control
  • Decision service design and documentation

Descriptive object texts

I cannot emphasize enough the importance of good descriptive texts for BRFplus objects such as formulas, decision tables, table operations, and especially for the more technical expressions, such as database lookups and procedure calls. When people with a technical background start modeling business rules, they tend to apply the same patterns they use for programming to the authoring of business rules in BRFplus. This is especially true when it comes to defining object names. And often, things get even worse when we look at the object texts. Moreover, many IT people configure the BRFplus workbench so that the technical object names are shown in the user interface instead of the texts.

The following example shows a pricing ruleset. Although simple in its logic, it looks complex. Names with technical prefixes have been used. The names do not explain what the objects are used for. Also, the names include German abbreviations, maybe because the data objects are bound to the Data Dictionary where German abbreviations are still common in some modules.

WB_NAMES.PNG

How can we improve this? It all starts with making the right personalization settings. To open the personalization dialog, use the highlighted icon in the BRFplus workbench.

Pers_Icon.PNG

On the General tab of the Personalization dialog, make sure the Show Technical Names checkbox is deselected. By the way, if you want to learn more about the various personalization settings, choose Show Quick Help from the background context menu. Most of the available options have an explanation attached that helps you understand the effect of each setting.

Pers_Texts.PNG

Once the Show Technical Names option is deselected, the example from above looks like this:

WB_Texts.PNG

Now, it is very clear what this ruleset is used for. It is easy to understand the meaning of each data object and expression. Even people without technical expertise are able to read and understand the business rules.

For each object in BRFplus, two text fields are offered:

  • Short Text (up to 20 characters)
  • Text (up to 80 characters)

When both are maintained, BRFplus uses the short text by default. If the short text is missing, BRFplus uses the text, which provides a lot of space to describe the object well. So, instead of entering a cryptic short text, just leave it empty and use the Text field only.

formula_text.PNG

Texts have even more advantages over names. While names adhere to restrictions known from development and database objects, texts do not have any such restrictions. They can be translated into several languages which make the rules including all used objects not only form English sentences but also form sentences in other supported languages such as Portuguese, Spanish, Chinese, German, and so on.  Also, special characters such as the German Umlauts are supported. If you like, you can go to extremes and insert a text like the following – no problem:

bad_text.PNG

In case you have bound a data object to a Data Dictionary data element, you can still overwrite the texts to customize the appearance according to the needs of the target group. And remember – a major part of the target group are business experts, not just developers. Needless to say, changing a text is automatically reflected in all the places where an object is used. 

Technical expressions such as a database lookup expression (selects data from a database table) or a procedure call expression (calls an ABAP function module, an ABAP method, or an SAP HANA procedure) can be nicely described with texts, too. A text such as “Retrieve business partner properties” is much better than “SELECT NAME AGE … FROM BUT000”.

The same is true for complex conditions that may be formulated as questions with the help of the text property. In the following example, a table operation expression is used to get the total for a month out of a table.

to_expr.PNG

All these features in BRFplus contribute to a so-called Domain Specific Language (DSL), that is, business-readable instructions for the execution of the decision service. Rüdiger Plantiko has recently published a blog with a nice explanation of this principle using a real-life example.

At best, you start with a business vocabulary defined by the functional experts. Then, this vocabulary is translated into BRFplus objects and used throughout the rules. I have seen complex business rules that were understood and owned by business teams within a few days. A positive side effect of this approach is that feedback for improvements can be discussed between IT and business without any translation step.

Object Documentation

Each object in BRFplus can be documented. You can find the documentation input field in the general data section. Documentation can also be language-dependent.

docu_1.PNG

As soon as documentation is available for an object, you will find a new icon in the top row. Just click on it to let the system take you directly to the documentation tab.

docu_2.PNG

In addition, if documentation has been maintained for an object, this is also reflected in other places in the workbench, such as the help menu or the object menu, which will show you the object documentation in a popup.

/wp-content/uploads/2012/12/docu_3_166822.png

Additionally, rule documentation can also be inserted directly when creating rules. This is part of the so-called rule header that can be made visible with the glasses icon, or with rule-specific menu. Good rule documentation can help a lot to introduce the decision service logic to new experts, thus making your projects more efficient.

rules.PNG

Since each rule in a ruleset has exactly one documentation string, we recommend not making the rules too big. The following figure shows a bad example (rule #3), followed by a better one (rules #4 and #5):

formulas.PNG

Expression result values

Each expression in BRFplus has exactly one result data object. This can be an element, a structure (with components of type element, structure, or table), or a table (with an element of a structure as its line type). In a rule, a decision is made about which part of the result should be taken over into the context, and how this should be accomplished (either updating a data object or inserting it into a data object of type table). It is, for example, possible to use a decision table with 3 result columns but take only 2 result values over into the rule context. The example below shows a decision table with two result columns, Base Price and Explanation. BRFplus has automatically generated a result structure (“Result Structure Of Table with Product Prices incl. Discounts”) with these two components.

dtab2.PNG

In the rule, it is possible to update the context data object Base Price only and ignore Explanation.

rule5.PNG

It is further possible to map the result of the decision table to another context data object. Although the table returns Base Price, I can set Price as the context data object to be updated by using the little highlighted menu.

rule6.PNG

Sometimes you may not want to return a result. This may be the case when your expressions only perform actions. If this is the case, make this clear in the rule by using the respective option.

rule7.PNG

For loop expressions and call procedure expressions, it is possible that no specific result is to be returned and mapped to a context field. Instead, the context is updated within the loop. Nevertheless it is good practice to use a result, ideally, the updated data object. This makes clear to the reader of the rule what is changed during rule execution.

loop.PNG

Often, rules authors are not clear about all the options BRFplus provides. Instead, workarounds are applied that make the rules look more complex than necessary.

Rule catalogs

Rule catalogs are a very efficient means to organize business rules and related artifacts. One object can be used within many different catalogs. Structuring folders can be created, and even referencing between catalogs is possible.

catalog.PNG

Catalogs optimized for specific user groups can be preset in the personalization settings. It is further possible to limit the navigation pane to catalogs only. If you do so, the appearance of the BRFplus workbench can be simplified significantly.

Access control

Catalogs can be used to simplify the navigation in the BRFplus workbench. Business experts are enabled to find their content quickly. Nevertheless, they may not be allowed to change all those objects. Especially objects like functions or technical expressions may be changed by technical experts only. To this end, authorization checks are available in BRFplus. Should you feel that this is still not sufficient or flexible enough for your use case, exits, such as the authorization exit, can be used. A separate document has been provided to explain how to use exits.

Decision service design and documentation

Finally, a very important topic is the documentation of decision services and business rules. I recommend using so called decision maps. A decision map is a high-level process description with a focus on the decision services involved. No separate tool is required for the creation of a decision map. Microsoft PowerPoint and comparable tools will do the job.

Picture1.png

Decision maps show non-technical people where decision services are invoked. They are decision-centric, leaving out many technical implementation details. A decision map does not replace an architectural diagram or a business process model. These are, however, intended for technical experts.

For each decision service a separate document should be created that documents the decision service interface and implementation. I have created a template document that you may download and use.

Other interesting blogs I recently read about BRFplus


To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member

    Hi Carsten,

    Nice blog, As I read through this blog I remembered few missing features ( at least as per my understanding) in BRF+ decision tables,  I thought I would highlight here.

    1) The column context data of one column is not available in another column, for example if I have a decision table with one column with  expression ( which return result object of type element) and if the expression needs to know the value in other columns of the same row in the decision table  to return a value ( it could be a formula expression), as per my knowledge we do not have a way to read this value, kindly correct me if am wrong.

    2) It would great if we have a system variable which stores the index of current line of decision table being processed during runtime something equivalent to SY-TABIX, I do not have a use case to support this one but I have a feeling it might help.

    awaiting your reply, once again thank you for another great blog.

    Thanks

    Santhosh Cheekoti

    (0) 
    1. Carsten Ziegler Post author

      Santhosh,

      You are right with the first point. We have an SAP-internal mechanism that may be released for usage by customers some day.

      Concerning the second point: I took it on my list. Will discuss it internally. Probably we need more customer pull for such a feature to invest.

      Regards,

      Carsten

      (0) 
      1. Former Member

        Hi Carsten,

        Awaiting to see how to handle this kind of scenario, and just another reminder of your promise to release documentation on custom expressions, we have a use case in our current project to create one, we are struck at UI design part ( not able to add the object selection menu on the webdynpro UI).

        (0) 
        1. Carsten Ziegler Post author

          Writing for the paper for customer expression and action typesis done. The paper is in internal review stage. Don’t know how long this will take. But once it is final, I will publish it in SCN.

          ๐Ÿ™‚

          (0) 
  2. Stephen McDougall

    Hi Carsten,

    There does not appear to be any BRFplus content in ASAP. It would be good if these (and future) best practices made their way into ASAP.

    Thanks

    Stephen

    (0) 

Leave a Reply