Friday 25 November 2016

Visualizing SAP HRF Rule Results in SAP Lumira – Part 1

SAP HANA Rules Framework Overview

SAP HANA Rules Framework is perfect for handling complex analytical rule constructs in real-time (online) and batch (offline) scenarios and makes the best use of the power of SAP HANA in order to achieve this. The built-in Fiori user interface that is distributed as part of SAP HRF is excellent at providing rule creation and management and allows rule results to be displayed in a textual manner. SAP HRF is all about providing the ability to allow business users to control, influence and personalize decision making in highly dynamic scenarios within the organisation in the most efficient and robust manner. Outside of SAP HRF it is the calling applications responsibility to make use of the decision results and actions that SAP HRF has returned.
Whilst the result set displayed by the SAP HRF user interface is informative, this can often be greatly enhanced by using a presentation tool to graphically represent the HRF output. One of the easiest ways of providing this type of graphical rendering is to use SAP Lumira. As a fairly novice user of SAP Lumira I am not going to delve much into how to use this tool – there are plenty of examples of this already in existence – this narrative is aimed very much more at describing the interfaces between SAP HRF result views and how to consume them in SAP Lumira.

I am going to lead you through a simple example by taking an SAP HRF rule, consuming the results of that rule in SAP Lumira, modifying the rule so that different results are obtained before refreshing SAP Lumira to present the updated results.

HANA Database Entities

Database Tables

First of all I will start with a very simple fact and dimension tables:

Fact Table SALES_QTY

SALES_QTY

id  product_id description sales_month budget_qty actual_qty

1     A1010       Shoes         01/09/2015      200       210
2     A1010       Shoes         01/10/2015      200       190
3     A1010       Shoes         01/11/2015      200       205
4     A1010       Shoes         01/12/2015      200       170
5     A1020       Boots          01/09/2015      50         75
6     A1020       Boots          01/10/2015      50         65
7     A1020       Boots          01/11/2015      50         70
8     A1020       Boots          01/12/2015      50         47
9     A1030       Trainers 01/09/2015       90        105
10   A1030       Trainers 01/10/2015       90        102
11   A1030       Trainers 01/11/2015       90         85
12   A1030       Trainers 01/12/2015       90         88

Dimension Table PRODUCT

PRODUCT

product_id   description
A1010            Shoes
A1020            Boots
A1030            Trainer

SAP HANA Rules Framework Artifacts

Vocabulary

I have represented the fact and dimension table in an SAP HRF vocabulary called sales. The vocabulary maps all the elements of both tables into data objects “saleshistory” and “product” respectively and uses a one to many association between product and sales history.

Rule Service

I then create a rule service called “Sales Analysis” by defining it with the following properties: –

Visualizing SAP HRF Rule Results in SAP Lumira – Part 1

In particular I make sure that the Consumption Artifact is of type “View” and the Resulting Data Object is “product” with keys “product_id” and “description”.

The “View” Consumption Artifact is important as it dictates SAP HRF create a HANA column view to hold the rule determination result. This view is stored in the Column View folder of the SAP_HRF database schema. This view is created in the format “<package>::<rule service name>.VIEW”. As I created my SAP HRF application in the package “sap.demo-store.sales.resources” my view is referenced by the name “sap.demo-store.sales.resources ::Sales Analysis.VIEW”

The “Resulting Data Object” allows me to specify the business entity I wish rules to be evaluated against. I have chosen the data object “product” so that I can analyse the sales results for my individual products.

I also provide an output called “SalesQuantity” – for “View” artifacts an output is mandatory. By specifying an output in the rule service that I defined in my vocabulary it allows me to view my rule results in the SAP HRF Fiori UI whilst also providing context to the results. The output contains two integer input parameters “Budget_Quantity” and “Actual_Quantity”.

Rule

My rule is entitled “Sales Below Budget” and for simplicity is a text rule rather than a decision table rule. The objective of this rule is to evaluate those products where the average sales quantity over a period of time is less than the equivalent budget sales quantity over the same period. I initially set the time period to be over the last sales month so that the rule condition and output parameters look like those below
Visualizing SAP HRF Rule Results in SAP Lumira – Part 1

I have set my outputs so that they provide the average sales quantity figures across Q4

Rule Determination

When I test the rule service in the SAP HRF Fiori UI the rule determination engine provides 3 results, one for each product. December was a poor month for sales as all product sales quantities fell below their budget values.

Visualizing SAP HRF Rule Results in SAP Lumira – Part 1

No comments:

Post a Comment