Please note that the following model has been implemented in SPS06 (revision 60 and onwards). I am not sure about the feasibility of this approach on the earlier revisions. The observations on the below model are based on my personal experience and opinion.
As mentioned in the earlier blog Implementation of WTD, MTD, YTD in HANA using Script based Calc View calling Graphical Calc view, let’s look into an option to populate the Input parameters for the Graphical Calc view using the enhanced functionality of Input Parameters.
Rules of the game remain same i.e. same business requirements, assumptions, Sample data and Projections with Constant columns for Pruning, as mentioned in the earlier blogs:
This approach outlines the functionality of Derived From Table property of Input parameters. With this functionality the SELECT FROM logic in Scripted Calculation view can be replaced eliminating the need to create Scripted Calc view for data derivation required for the Input Parameter value ranges.
The View model can be defined as follows:
The key features of the model are as follows:
- Graphical Calc View, providing query column pruning (as compared to the Scripted Calc view)
- Projections with Constant columns for effective query pruning for performance
- Input Parameters for Filter pushdown
- Derived Input parameters to implement data derivation logic
To implement the data derivation logic, you may have to use the mapping table which contains the required data already mapped and persisted in the system. The derivation is based on the data of this table. The Derived Input Parameter would provide the logic similar to:
SELECT mapping_value FROM mapping_table
WHERE lookup_value = user_input_value;
In the case to derive the data range for WTD, MTD and YTD, a mapping table is defined which contains the Week Start Date, Month Start Date and Year Start date mapped to each of the Calendar Day. The Input parameter with Derived from Table performs lookup on this mapping table to derive the required dates for the date ranges.
The mapping table can be defined as follows:
The mapping table has mapping for each of the date with the required Start dates for Week, Month and Year.
The input parameters can be defined as follows:
The input parameter can be used in the Projection filter as specified below:
The query on the model can be executed without impacting the performance.
The execution plan shows that the filter has been pushed down and the projection filter has been implemented.
In my personal opinion, this approach is most recommended. It provides all the positive features of Graphical Calc views like:
- Ease of development using Graphical option
- Projection pruning with Constant columns
- Filter Pushdown with Input Parameters
- Derivation logic in the Input Parameters
The mapping table to derive the data is mostly available in the application model. In case, the derivation logic is complicated, then it may require to simplify the logic and persist the data in the system.
As always, please feel free to comment on the document.
Thanks for your time and encouragement so far…