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 wheels that is right fit to a vehicle based on make, 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.
Facts
- 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
Usecase
Consider a major wheel retailer company that would want to filter the wheels based on the vehicle parameters like model, make and manufacturer. Besides, they also a set of rules – which have to be applied - when the filtering of wheels is done.
Solution
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
(a) Data Model
I have created two database tables named VEHICLE and WHEEL. VEHICLE table contains all the metadata about the vehicle and WHEEL contains all the metadata about the wheels that would later be suggested as fitting to a particular vehicle.
(b) Decision Table Data Foundation
You can use the tables to create the data foundation of the decision table
Decision Table
- Add the Attributes, Data Foundation, to create Condition and Actions of decision table as
Note: Action as Parameter – ISWHEELPROPER, which is set to 1 if the wheel is proper fit for vehicle or 0 otherwise. Through this decision table would do first set of filtering by making the database record feed in an extra column i.e. ISWHEELPROPER with 0 or 1
- Fill the decision table with Condition Values and Action Values
- Finally, Save, Validate and Generate Decision Table.
This would generate the Result View that would be used in Calculation View
For more details on modeling decision table refer my blog series
Calculation View
- 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 Vehicle Make, Year and Model based on which the suggestions of right-fit wheels would be made.
- Filter is also based on the ISWHEELPROPER =1 (attribute from the decision table) i.e. The right fit is determined by two factors (a) input parameters of calculation view and (b) ISWHEELPROPER attribute from decision table
- Finally, Save , Validate and Generate Calculation View
Test
Use Data Preview of Calculation View to test the result 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 Server 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 !