MDX solves a couple of problems OData can't. So what if you want to use MDX in your SAP UI5 applications? You build a SAP UI5 model and bindings to work with XML/A backends. This allows you to build rich OLAP applications using any component in UI5
1. Beyond OData
Introducing
the XML/A model for UI5
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
Roland Bouman
Business Intelligence Consultant & Developer
Just-BI.nl (Rijswijk)
Twitter: @rolandbouman
Blog: http://rpbouman.blogspot.nl
2. Requirement & Environment: Cost Reporting
• Base Cost Measures:
• Actual
• Planned
• Derived Metrics:
• Delta: Planned – Actual
• Relative: Delta / Planned * 100%
• UI:
• Dropdown filter for Time/Period
• Drilldown tables with Bulletcharts
• UI5
• Time:
• Current Period (Month)
• Year to Date
• Hierarchical Breakdowns:
• Cost Centers
• Cost Elements
• Lazy loading
• Backend:
• HANA 1.0
• Data from BW model
• Front end: UI5
• OData (.xsodata)
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
4. Datamodel: BW on HANA 1.0
• Fact Table:
• Amount
• Cost type (planned or actual)
• Keys to dimension tables
• Dimension Tables
• Calendar Dimension Table
• Cost Center Table (Parent/Child)
• Cost Element Table (Parent/Child)
• Texts (Labels)
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
5. Cost Hierarchy Data Model
• Hierarchies
• Cost Element
• Cost Center
• Adjacency list:
• Id column (primary key)
• Parent Id column (foreign key to Id)
• Recursion
• Non-leaf nodes
• Only access to direct children
• Variable Depth (Ragged)
• Leaf nodes
• Corresponding Fact table Rows
Dimension Table
Id (primary key)
Parent Id (foreign key)
Fact Table
Dimension Table Id (foreign key)
Metrics (to be aggregated)
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
6. Challenge: Recursion & Aggregation with OData
• Recursion
• OData can handle Recursive relationships (navigation properties)
• Think: Lazy loading / Tree-like navigation
• Aggregation
• HANA .xsodata can handle aggregation
• Recursion & Aggregation:
• Aggregation of fact rows of all descendants of any given non-leaf node
• It needs to not be dead slow, too
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
7. Solutions for Recursive Aggregation?
• All Client-side
• Client caches hierarchy + data, client-side aggregation
• Add a Service
• Server-side logic (procedure, xsjs script) handles recursion & aggregation
• HANA 1.0 has no recursive SQL constructs
• Change the Data
• Flatten parent/child hierarchy into a leveled hierarchy (ETL)
• Each level becomes a column
• Periodical batch ETL required (no realtime)
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
8. The Alternative: MDX
• Multi-Dimensional Expressions
• OLAP (Online Analytical Processing)
• Designed for Aggregation
• Web Service Protocol
• XML/A: “XML for Analysis”
• Native HANA support
• Analytic Views
• CUBE Calculation Views
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
SELECT {
[Measures].[Actual]
, [Measures].[Planned]
} ON COLUMNS
, Descendants(
{[Dim].[Hier].[Level].Members}
, 5
, SELF_AND_BEFORE
) ON ROWS
FROM [Cube]
WHERE {[Date].[Hier].[Month].[201811]}
9. SELECT {
[Measures].[Actual]
, [Measures].[Planned]
} ON COLUMNS
, Descendants(
{[Dim].[Hier].[Level].Members}
, 5
, SELF_AND_BEFORE
) ON ROWS
FROM [Cube]
WHERE {[Date].[Hier].[Month].[201811]}
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
12. WITH
MEMBER [Measures].[Actual YTD] AS
Aggregate(
Ytd({[Date].[Hier].CurrentMember})
, [Measures].[Actual]
)
MEMBER ...more calculated members...
SELECT ..
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
13. Web Service Protocol: XML for Analysis (XML/A)
• It’s just a Web Service Protocol
• Http / Https
• SOAP Protocol (POST)
• XML used for request and response
• What can it do?
• For Building OLAP applications
• Discover: Get metadata
• Execute: run MDX Queries
• HANA
• XS Application
• Empty .xsxmla file enables XML/A
• Analytic view
• CUBE Calculation view
• Javascript Client Library
• https://github.com/rpbouman/xmla4js
• Interactive MDX Query tool
• https://github.com/rpbouman/pash
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
14. XML/A: Discover and Execute
• Discover: Metadata/Rowset
• Catalogs (packages)
• Cubes (Analytic and CUBE Calc views)
• Dimensions (Attribute and DIMENSION Calc views)
• Hierarchies
• Levels (Attributes)
• Members (Attribute Values)
• Measures
• Properties (Attribute Values, Builtins)
• Execute: Queries/Dataset
• SELECT
• Axes
• FROM
• Cube (in HANA: a View)
• WHERE
• Special “slicer” axis
• Not a predicate based filter !
• Calculated Members
• Derived Measures
• Named Sets
• Custom groupings
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
15. Integration: UI5 Model and Bindings
• Model:
• Provides data access
• Handles back-end requests
• Factory for Binding objects
• Web Service Protocol:
• Normally, OData
• Now, XML/A
• Bindings
• Glues components to Model
• Typically created by the Model
• Binding Types
• Property
• List
• Tree
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com
17. Summary
• MDX Solves a couple of hard problems
• Recursion/Aggregation problem
• The YTD problem and many more advanced aggregations
• XML/A lets you do MDX over HTTP
• HANA Supports XML/A (and MDX)
• Xmla4js is an Open Source XML/A Client in Javascript
• Extend UI5 JSON model + bindings to use Xmla4js
• Now you can do OLAP with any UI5 component through databinding
Roland.Bouman@just-bi.nl – Roland.Bouman@gmail.com