Filtering Rules using SAP HANA Decision Table
Filters are often applied by the business users or rule designers to control the output based on the multiple parameters specific to any industry like filter customers that have a specific plan in telecom industry or filter deals based on autmobile manufacturer, model etc. or filtering customers that have specific policy in Life Insurance sector or filtering messages in your inbox. This blog will walk you through the process of defining rules and using them to filter the content based on specified action and/or input.
- Decision Table directly does not support filtering of rules. It will be used in consonant with Calculation View to achieve filtering.
- There could be several approach based on the requirements like performance, filtering to be done first and then the rules are to be executed or vice versa etc. In all the approach Calculation View has to be used to filter no-matter at which stage you choose to filter.
- This solution could be applied since HANA release SP06
There is an online company that offers discount coupons on car deals from various dealers based on the car model and manufacturer. A set of rules are run to decide the discount given by various dealers from different regions. Customers can use these discount coupons with the dealers when purchasing the car.
Here is a step-to-step guide that could be used to filter rules using decision table based on the usecase described above. Explore this solution that has been divided into 3 sections (a) Data model (b) Decision Table model (c) Consumption model
Note: All the images are based on modeling done on HANA Studio SP07, but the same usecase could be designed
in same way in SP06 as well.
(a) Data Model
I have created three database tables named CAR, DEALER and DISCOUNT_COUPON. CAR table contains all the metadata about the car, DEALER contains all the metadata about the dealers and their location and DISCOUNT_COUPON contains discount information that would later be suggested to the customers who are looking for best buy before purchasing the car.
(b) Decision Table Modeling
- Use the tables to create the data foundation of the decision table
- Add the Attributes from the data foundation to create Condition and Actions of decision table
Note: Action is a Parameter – DISCOUNT, which is set to after the rules are executed.
- Fill the decision table with Condition and Action values
- Finally, Save, Validate and Generate Decision Table
Note: This would generate the Result View that would be used in Calculation View.
For more details on modeling decision table refer my blog series
- Use the result view of the decision table in Projection shown as Projection_1
Note: You can find result view in “_SYS_BIC/<your-package>/<your-decision-table-name>_RV
- In this Projection_1, create Input Parameters and Filter.
- Input parameter are the one the you want user to input like Model and Manufacturer – based on which the deals from various dealers would be suggested.
- Filter is based on the Model and Manufacturer entered by the user as INPUT PARAMETERS
- Finally, Save , Validate and Generate Calculation View
- To test the outcome of the Calculation View, use Data Preview of Calculation View
(c) Consumption Model
Calculation view can further consumed using OData service.
You can thus use decision table to control the items that are consumed in your application, and can bring in ability of controlled consumption to the database. Follow this blog to successfully create custom application in HANA especially where filtering-rules are needed. Do write in your suggestions and feedback. If you have any queries on filtering rules then drop me comments, I would be happy to help you !