SAP HANA Modeling Overview SAP HANA Product Management
November, 2013
SAP HANA Modeling Overview
SAP HANA Modeling Views - Overview Data and Processing in SAP HANA In-Memory Data Stores: Column- and Row Store Optimized for Query and OLTP Workload SQL & OLAP Processing and specific Calculation Operators Application Function Library for specific Scenarios, e.g. Predictive Analytics
Modeling in SAP HANA Information Models (SAP HANA Views) are optimized for SAP HANA Engines and Calculation Operators Data/Columns are classified as Attributes or Measures in SAP HANA Views Attributes – descriptive data (known as Characteristics SAP BW terminology) Measures – data that can be quantified and calculated (known as key figures in SAP BW) No materialized aggregates
Three levels of modeling: Attribute View > Analytic View > Calculation View
© 2012 SAP AG. All rights reserved.
Public
3
SAP HANA Modeling Views - Overview
Attribute Views
Analytic Views
Calculation View
• Compose a dimensional view • Combines Fact-Tables with • Great flexibility for advanced use with a series of attributes derived Attribute-Views to Star-Schema- • Approach to model custom from a collection of tables or OLAP Cube-like objects for scenarios like e.g. Master Data Views multidimensional reporting. Combined use of Multiple-Fact Highly re-used and shared in • Stores no aggregates and massTables/Analytics Views Analytic- and Calculation Views aggregates on the fly Build Models on Normalized Data Used to build Hierarchies • Hierarchies are key for multi Re-Use and stack views Hierarchies are key elements in dimensional access (navigation, Make use of custom scripted views use with Analytic View for multifiltering, slicing and aggregation) dimensional reporting
© 2012 SAP AG. All rights reserved.
Public
4
SAP HANA Modeling Views - Multidimensional Model Scenario Reporting Tools can usually directly consume HANA Calculation Views or Analytic Views.
Calculation View
Multidimensional Tools support Hierarchies for Navigation, Filtering and Aggregation and HANA Prompts (Variables & Input Parameters) for efficient Pre-Filtering of Data.
Calculation Views are usually build upon Analytic-, AttributeViews, and Column Tables
© 2012 SAP AG. All rights reserved.
Analytical View
Attribute View
Column Table
Public
5
SAP HANA Modeling Views - Normalized Data Model Scenario
SAP HANA Calculation Views provide the means to model sophisticate views based on normalized data structures.
SAP HANA Calculation Views typically feed data to Business Applications, like SAP HANA XS build Applications
Complex Calculation Views demand a more explicit intent and control of the modeled set-based data flow, i.e. slicing, aggregation and filtering of sets as input to joins, unions etc.
See SAP Note 1857202 © 2012 SAP AG. All rights reserved.
Public
6
The SAP HANA Studio Model Editor Model Scenario
General View Properties, Semantic Information
The Graphical Model Editor Standardized graphical editing across different SAP HANA view types Build of different common panels – Scenario provides Overview – Semantic node provides better summary of output structure of the model + editor view of output objects + general view properties – Logical-Join- and Data Foundation-Nodes are specific to Attribute- and Analytic Views – Calculation-Views are modeled in the scenario panel based on a palette of node-objects like join, union, etc. to compose a custom data flow.
© 2012 SAP AG. All rights reserved.
Logical Join of Data Foundation & Dimensions
Data Foundation
Public
7
SAP HANA Studio Modeling Environment
SAP HANA Studio – Modeling Perspective The SAP HANA Modeler within the SAP HANA studio • Eclipse-perspective targeting Power Users for Content Design • Graphical Information Model Design Environment for HANA optimized Models ‒ Attribute-, Analytic- and Calculation Views ‒ without materialized aggregates
• Development of advanced Calculation Models ‒ SQL & SQLScript-based, Use of Application Function Library- and SQLScript-based Stored Procedures © 2012 SAP AG. All rights reserved.
Public
9
SAP HANA Studio – Modeling Perspective Typical View-Windows
The SAP HANA Modeler Eclipse-perspective
Perspectives
Perspectives are build upon different ViewWindows in the Eclipse environment
© 2012 SAP AG. All rights reserved.
Public
10
SAP HANA Studio – Modeling Perspective The SAP HANA Modeler within the SAP HANA studio • Quick Launch access to common modeling tools
Wizards for creating / graphical designing HANA Content objects as Information Models
Managing the work environment and system connections
© 2012 SAP AG. All rights reserved.
Actions or wizards for working with content
Actions or wizards for working with data or working with a SQL console
Public
11
SAP HANA Studio – The HANA System Environment
The content contains the HANA Studio Models meta data, e.g. for Analytic Views, Attribute Views, Calculation Views. The content is organized in packages.
The catalog contains the HANA database schema and the stored objects, like column tables
From content tree and the package structure the Editor to build new HANA Views can be called © 2012 SAP AG. All rights reserved.
Public
12
SAP HANA Studio – The Unified Model Editor Model Scenario
General View Properties, Semantic Information
Unified Graphical Editor Standardized graphical editing across different HANA Database view types Build of different common panels – Scenario provides Overview – Semantic node provides better summary of output structure of the model + editor view of output objects + general view properties – Logical-Join- and Data Foundation-Nodes are specific to Attribute- and Analytic Views – Calculation-View* supports different nodes
Logical Join of Data Foundation & Dimensions
Data Foundation
*New in SAP HANA SPS6 © 2012 SAP AG. All rights reserved.
Public
13
Getting Started with Modeling Modeling Attribute Views Modeling Analytic Views Modeling Calculation Views
Modeling Attribute Information – HANA Attribute Views What is an Attribute View? • ... are the reusable Dimensions Used for Analysis which add context to data.
Semantic Attribute Information
• Can be regarded as Master Data Views Build a semantic attribute information collection from various source tables (e.g. join ‘Plant’ to ‘Material’) Can be re-used as dimensions in Analytical Views Specific time-based Attribute Views are supported
© 2012 SAP AG. All rights reserved.
© SAP AG 2011
Attribute Data Foundation
Public
15
Modeling Attribute Information – HANA Attribute Views What are the capabilities of Attribute Views? • Attribute Views supports Description Mapping & Text-Join Lookup master data tables e.g. used for handling of multi-language master data Various joins types between data foundation tables Time Dimension Attribute Views Hierarchies (Level, Parent-Child)
Calculated Attributes (static or dynamic calculations) Define filter values on column …
© 2012 SAP AG. All rights reserved.
© SAP AG 2011
Public
16
Attribute View – Data Foundation Building the Attribute Data Foundation • An Standard Attribute View is a join of several tables Referential, Inner, Left Outer, Right Outer and Text Join Text Join are used to join a text table to a master data table to lookup language dependent texts like product name
Filter (static or dynamic) on source object columns The output structure of the view is explicitly defined Calculated attributes added
© 2012 SAP AG. All rights reserved.
Public
17
Attribute View – Define View Semantics Define Semantic Output Representation of Attributes • Classify the Columns and Calculated Columns as attributes and key attributes
• Maintain General View Properties Default Client, Enable Analytic Privileges
• Attributes can be specified as hidden, if only used in calculated attributes
• For each output column a ‘label column’ can be specified, which points to another column containing a description for the original column
• Define Attribute Hierarchies Level Based and Parent-Child Hierarchies
© 2012 SAP AG. All rights reserved.
Public
18
Attribute View – Save, Activate and Preview Create executable version of the view • Save the view: Creates a Repository/Design-Time Object This information model itself is not visible to reporting tools • Activate the view: Creates a Catalog/Run-Time Object This creates a database view in schema ‘_SYS_BIC’ (a so-called ‘column view’) This column view can be accessed from reporting tools
• Data Preview
© 2012 SAP AG. All rights reserved.
Public
19
Getting Started with Modeling Modeling Attribute Views Modeling Analytic Views Modeling Calculation Views
Modeling Facts and Dimensions – OLAP Star Schemas What is an OLAP Star Schema? • Star schema usually has one fact table containing the key figures • Key figures are measureable numbers • Dimensions describe the key figures and enrich them with additional information (usually master data)
HANA Analytic Views build and extend this concept of a OLAP Star Schema Model
• Cardinality in star schemas is generally N:1 fact to dimension
• Joins in star schemas are generally Left Outer Joins • Slicing and dicing is a feature whereby users can take out (slicing) a specific set of data of the cube and view (dicing) the slices from different viewpoints. © 2012 SAP AG. All rights reserved.
Public
21
Modeling Facts and Dimensions – HANA Analytic Views What is an Analytic View? • Can be regarded as Cube-/OLAP Star Schema-like, but without storing aggregated data Data is read from the joined database tables
Joins and calculated measures are evaluated at run time
• Fact Data from the ‘Data Foundation’ is joined against modeled Dimensions (Attribute Views) fact table contain the key figures ‘Measures’
Semantic Information
Dimensions describe the key figures and enrich the data Logical Join of Data Foundation & Dimensions
HANA Analytical Views are highly optimized for aggregating mass data
© 2012 SAP AG. All rights reserved.
© SAP AG 2011
Public
22
Modeling Facts and Dimensions – HANA Analytic Views What are the capabilities of Analytic Views? • Defining Calculated & Restricted Measures Aggregation (sum, max, ..) Expressions / Operators / Functions
• Currency and Unit Conversion • Variables and Input Parameters Variables and Parameters are usually entered manually by the users using UI Prompts Note: Variables are bound to attributes and used to filter using WHERE clauses (Single, Interval, Range).
© 2012 SAP AG. All rights reserved.
© SAP AG 2011
Public
23
Analytical View – Structural Overview Semantics Information • Classify the Columns and Calculated Columns as attributes and measures. You can also create variables/input parameters, and assign variables to the columns in the Semantics node.
Semantic Information
Logical Join of Data Foundation & Dimensions
Logical Join with Attribute View • Join attribute views to these tables in the Logical Join node. Data Foundation
Data Foundation of Fact Data • Create a fact table by adding and joining the tables
© 2012 SAP AG. All rights reserved.
Public
24
Analytical View – Data Foundation Building the Analytic View Data Foundation • Fact Data is modeled in the ‘Data Foundation’ pane Add source fact table(s), which contain the key figures ‘Measures’
Note: multiple tables can be joined, however measures may only be selected or derived from one of the table Select attributes and measures from table(s) this defines the data foundation Input Parameter can be defined
Filter on source object columns
Data Foundation
• Can be based on any table column • Column does not need to be selected for output ([key] attribute) • Input Parameters* are supported.
*Since SPS6 Input Parameter references can be used (typed in) for filters on data foundation in Analytic and Attribute Views © 2012 SAP AG. All rights reserved.
© SAP AG 2011
Public
25
Analytical View – Logical View Building the Logical Analytic View • Define joins between Attribute Views and Data Foundation Typically Left Outer-, Inner-, Referential- or Temporal Joins
© 2012 SAP AG. All rights reserved.
© SAP AG 2011
Public
26
Analytical View – Logical View Building the Logical Analytic View • Creating Calculated Columns in the Logical View Output Aggregation (sum, min, max, count), Counter (DistinctCounts) Data Types (decimals, numbers etc.) Expressions / Operators Functions (String, Date Math, Conversion…)
• Advanced Semantic Calculations Unit of Measure and Currency Conversion • Creating Restricted Columns Support constraints to apply for data used for calculating the measures
• Creating Input Parameters Prompted Parameter use e.g. in Calculation and/or Filters © 2012 SAP AG. All rights reserved.
© SAP AG 2011
Public
27
Analytical View – Define View Semantics Define Semantic Output Representation of the Analytical View
Set View Properties
Classify columns as attributes or measures Assign Variables to columns Create Measures Display Folders Order Columns, specify as hidden, select label columns, …
© 2012 SAP AG. All rights reserved.
Inspect Hierarchies from underlying Attribute Views
Create Variables and Input Parameters
Public
28
Analytical View – Define View Semantics Define Semantic Output Representation of the Analytical View • Maintain General View Properties Default Client, Enable Analytic Privileges and further advance properties.
• Semantic Column Area Filter Variables can be directly specified and Variable Names specified with Filter-Information For Multidimensional Reporting Clients, Measure Display Folder can be defined to better structure measures Column Semantic-type can be specified and full unit/currency conversion specifications Calculated column definition reviewed Where-used analysis of columns
© 2012 SAP AG. All rights reserved.
Public
29
Analytical View – Excursus Variable and Input Parameters What are Variables and Input Parameters? • Variables and Input Parameters Variables and Parameters are usually entered manually by the users using UI Prompts
Variables are bound to attributes and used to filter using WHERE clauses (Single, Interval, Range) Input Parameters are passed by Placeholders and used in Formulas (Attribute, Currency, Date, Static List) & Filters Variables can accelerate the joining of views by reducing the data set before join occurs
Input Parameter SELECT as Filter SUM(ORDER_QTY), COUNTRY FROM "_SYS_BIC"."eim260/SALES_DELIVERY_CV" ('PLACEHOLDER' = ('$$IP_COUNTRY$$', 'US')) WHERE ("CREATED_ON" BETWEEN ('20120101') and ('20120501')) AND ("DELIVERY_DATE" BETWEEN ('20120101') and ('20120501')) GROUP BY "COUNTRY" Variables Input Parameter in Calculations if("COUNTRY"= '$$IP_COUNTRY$$',"GROSS_AMOUNT",0)
© 2012 SAP AG. All rights reserved.
© SAP AG 2011
Public
30
Analytical View – Excursus Variable and Input Parameters Creating Variables • Variables and Input Parameters Revisited create variable dialog texts to be more self-explaining Selected Attributes in Variables are automatically defaulted as applied for the variable filter Variables can be directly created from the details area of the semantic node where the variable name is show along with the filter icon External views or tables for value help dialogs can be referred to. Special default values are now supported and can be authored via an expression editor – E.g. formulas as default like “date(Now())“ for today
© 2012 SAP AG. All rights reserved.
© SAP AG 2011
Public
31
Analytical View – Excursus Variable and Input Parameters Creating Input Parameters • Input Parameters Special default values are now supported and can be authored via an expression editor – E.g. formulas as default like “date(Now())“ for today – Evaluated expression will be shown, e.g. for now-function the day will be displays
External views or tables for value help dialogs can be referred to Semantic type for input parameter specifications
© 2012 SAP AG. All rights reserved.
© SAP AG 2011
Public
32
Analytical View - Save, Activate and Preview Create an executable version of the analytical view and preview • Save the view: Creates a Repository/Design-Time Object
• Activate the view: Creates a Catalog/Run-Time Object • Call the preview , for which there are 3 modes available Raw data (table display) Number of distinct values per column
Interactive graphical analysis Can create filters Number of records is limited (as specified in the SAP HANA Studio preferences)
© 2012 SAP AG. All rights reserved.
Public
33
Analytical View - Save, Activate and Preview Create an executable version of the analytical view and preview • Save the view: Creates a Repository/Design-Time Object
• Activate the view: Creates a Catalog/Run-Time Object • Call the preview , for which there are 3 modes available Raw data (table display) Number of distinct values per column
Interactive graphical analysis Can create filters Number of records is limited (as specified in the SAP HANA Studio preferences)
© 2012 SAP AG. All rights reserved.
Public
34
Analytical View - Run-time object: column view Activation creates a column view can be accessed from reports
Reports
Exposed like regular views via SQL/MDX interfaces
Column Store
Activate © 2012 SAP AG. All rights reserved.
© SAP AG 2011
Public
35
Getting Started with Modeling Modeling Attribute Views Modeling Analytic Views Modeling Calculation Views
Modeling Custom Scenarios – HANA Calculation Views What is a Calculation Views?
Application UI
• Calculation Views are composite views and can be used to combine other views Can consume other Analytical-, Attribute-, other Calculation Views & tables • Approach to model custom scenarios like
Combined use of Multiple-Fact Tables/Analytics Views Build Models on Normalized Data Re-Use and stack views Make use of custom scripted views
Calculation View
• Great flexibility for advanced use • Modeling Approaches: Graphical Modeler or SQLScript-based Editor
© 2012 SAP AG. All rights reserved.
Public
37
Modeling Custom Scenarios – HANA Calculation Views What are the capabilities of Calculation Views? • Graphical Calculation Views Can consume other Analytical-, Attribute-, other Calculation Views & tables Built-in Union, Join, Projection & Aggregation nodes Calculation View Besides flexibility provides additional features like DistinctCount calcualtion, dynamic joins, …. No SQL or SQL Script knowledge required • SQLScript-based Calculation Views
Attribute View
Can be regarded as a function, defined in the HANA-specific language “SQLScript”, which is build upon SQL commands or special HANA pre-defined functions.
Analytical View
Must be read-only. Calculation View © 2012 SAP AG. All rights reserved.
Column Table Public
38
Graphical Calculation View – Building the Scenario Designing the Calculation View Scenario Select View Type: Select Graphical or SQL Script Select Output Type: should the CV’s final output set aggregate measures or rather produce a list-like output without aggregating the measures. – Enable Data Category “CUBE” aggregates measures, then the default (top output)-node is pre-selected as an aggregation node (can be switched later) otherwise as an projection node If Data Category is left ”
if Data Category is set to ”DIMENSION” • The output node does not offer any measures but just attributes • The Calculation view is to be used with CUBEStarJoin enabled calculation views.
© 2012 SAP AG. All rights reserved.
Public
39
Graphical Calculation View – Building the Scenario Designing the Calculation View Scenario Composing a calculation flow with nodes – Projection, Aggregation, Join and Union-Nodes can be drag’n dropped from tools palette into the scenario and connected appropriate to demands – Contributing objects to a node, are now collapsed into the node
Adding table or view objects – Select via drag’n drop from catalog or content – search from repository & local project workspace – Catalog Tables, Calc Views (Graphical, Scripted), Attribute and Analytic views – Drop elements into node placeholders directly or connect later to nodes
© 2012 SAP AG. All rights reserved.
Public
40
Graphical Calculation View – Working with Nodes Working with the Projection-Node in the Scenario • Projection nodes can be added to add extra fields. For example, setting the Actual versus Planned indicator Drag a connection line between all the nodes
The output node will represent the data flow graph end
• Projection output set can be customized with Renaming, Calculated Columns, Input Parameters, Filters, ….
© 2012 SAP AG. All rights reserved.
Projection node as an intermediate node in the calculation flow
Public
41
Graphical Calculation View – Working with Nodes Working with the Aggregation-Node in the Scenario • In order to have further control of how the aggregation is done, it is beneficial to use the aggregation node in Graphical Calculation Views. When using the aggregation node you can specify which columns should be aggregated and also the aggregation type (sum, min or max). You can also add Calculated Columns to the node. These calculations will be performed after aggregation. Note: The definition of the specific aggregation type for calculated columns is maintained in the property view.
Selecting Measures as aggregated output of the node
© 2012 SAP AG. All rights reserved.
Public
42
Graphical Calculation View – Working with Nodes Working with the Join-Node in the Scenario • Used to query data from two data sources, which are joined by a specific criteria Inner-, Left/Right-Outer, Text- and Dynamic Join
If more than two tables have to be joined, join-nodes have to be used in a stacked-flow Join dialog window
Join properties can also be maintained in the properties view of the join details. © 2012 SAP AG. All rights reserved.
Public
43
Graphical Calculation View – Working with Nodes Working with the Union-Node in the Scenario • Union Operations When multiple result sets should be combined by using placing them on top of each other use the union-node
• Column Mapping in Unions In order for the columns from the different sources to go into the correct target, a mapping will need to be provided. This can be done via a drag and drop in the union editor area or by using Auto Map by Name in order to auto map columns by name between sources and target
© 2012 SAP AG. All rights reserved.
Define the UNION by mapping both Projection Nodes to the target
Public
44
Graphical Calculation View – Working with Nodes Working with the Union-Node in the Scenario • Using constants in unions When sources have a different number of columns, a constant value can be set for the source columns that do not have the target column and map the constant to the target column Allow to add unmapped columns that only have a constant mapping (without a match to any source column)
If targets column don’t yet exist, e.g. for constant mapping, they can just be added in the union
• Setting constant values The Constant Value can be set by right-clicking on the Target column, selecting “Manage Mappings”. Additionally it is required to specify a data type Example: The Planned vs. Actual indicator can now be set in the Union instead of defining the flag within a Projection node. © 2012 SAP AG. All rights reserved.
Public
45
Graphical Calculation View – Working with Nodes Best Practice for Joins and Unions • Be careful and do not JOIN Analytical Views, this could lead to performance implications as Analytical Views often expose mass data, where joins can be challenging • Instead Unions may be used alternativels, as union do not compare records between right and left table. Unions are simple set-combinings between these tables if the structure or the field mapping is identical. Unions are used to combine the result-set of two or more SELECT statements
© 2012 SAP AG. All rights reserved.
Public
46
Graphical Calculation View – Define View Result Set Define the structure of the Result Set of the Calculation View • Calculation View Result Set In the default node, a projection or aggregation node, below the semantic node, the output columns can be selected from its input node Add Attributes and Measures to the Output Define Calculated Columns or Counters
Define Input Parameters
© 2012 SAP AG. All rights reserved.
Public
47
Graphical Calculation View – Define View Result Set Define the structure of the Result Set of the Calculation View • Creating Calculated Columns Calculated columns in CV can combine data from multiple input source and thus measures across different subject areas
Calculated Column Editor can be used to create Calc. Measure and Attribute
© 2012 SAP AG. All rights reserved.
Public
48
Graphical Calculation View – Define View Result Set Define the structure of the Result Set of the Calculation View • Creating Calculated Columns and counters • In the default (last/top node (projection or aggregation) special calculated column can be defined
Special semantic measures: Amount with Currency and Quantity with Unit of Measure Counters: A counter is a distinct count of values from one or multiple attribute columns Note: counters can only be defined in calculation views
© 2012 SAP AG. All rights reserved.
Public
49
Graphical Calculation View – Define View Semantics Define Semantic Output Representation of the Calculation View • Maintain General View Properties Default Client, Enable Analytic Privileges and further advanced properties.
• Columns, Hierarchies, Variables/Input Parameters Classify columns as Attributes and Measures specify measure aggregation, if hidden, label columns, filter variables, measures folder, … Define hierarchies, variables, Input parameters Column Semantic-type can be specified and full unit/currency conversion specifications Calculated column definition reviewed Where-used analysis of columns
© 2012 SAP AG. All rights reserved.
Public
50
Graphical Calculation View – Save, Activate and Preview Create an executable version of the calculation view and preview • Save the view: Creates a Repository/Design-Time Object
• Activate the view: Creates a Catalog/Run-Time Object Activation will create the Column view that can be accessed by the front end tools or call the preview . In calculation views, data preview is also supported for intermediate nodes Column Store
Activate
© 2012 SAP AG. All rights reserved.
Public
51
Extending Models with advanced capabilities
HANA Hierarchies Authoring Hierarchies in Attribute- and Calculation Views • Hierarchy is a description of responsibilities /relationship of the different units/member that run the unit. • This relationship help to visualize the data for analytical purpose by organizing the same based on the relationship of various level of units / members. • In SAP HANA, we have a choice of creating 2 types of hierarchies, Level Hierarchy Parent Child Hierarchy • HANA Hierarchies can only be used by Multidimensional Reporting Clients.
© 2012 SAP AG. All rights reserved.
Public
53
HANA Hierarchies - Level Hierarchies Level Hierarchy Each level represents a position in the hierarchy It can be something related to time (Year, Quarter, Month, Day) or geography (Country, Region, State). Level Hierarchies are relatively easy as the various levels are either stored in different columns of the table or even in different tables (snow flake).
© 2012 SAP AG. All rights reserved.
Public
54
HANA Hierarchies - Parent Child Hierarchies Parent Child Hierarchy Represents the relationship which is recursive in nature. Defined as 2 table columns as pairs of predecessor and successor node IDs. Modeled in HANA by taking input as a FLAT table where the rows corresponds to the Hierarchy nodes and contains a node Id and a parent node id. Examples :
Company organizational structure Object levels: President – Vice President – Director Object type: Person Inventory BOM (Bill of Materials) Object levels: Product – Assembly – Sub-Assembly – Component Object type: Inventory item
© 2012 SAP AG. All rights reserved.
Public
55
HANA Hierarchies - Example of Parent Child Hierarchy For example, a company organization chart is made up of people. Some people are at different levels, and there are therefore relationships from one person to another. In order to show all of the relationships from the top of the company to the bottom (or the bottom to the top) We have to keep going back to the same table. That is recursion EMP
MGR
EMP_ID
LAST_NAME
MGR_ID
EMP_ID
EMP_ID
101
Frazier
?
FIRST_NAME
FIRST_NAME
102
Arthur
101
LAST_NAME
LAST_NAME
103
Greene
101
DEPT_NO
DEPT_NO
104
Rob
103
MGR_ID
MGR_ID
105
Bob
103
© 2012 SAP AG. All rights reserved.
Alias
Public
56
SAP HANA Currency Conversion HANA Currency Conversion logic follows the identical logic of the SAP ERP Currency Conversion. There is no refactoring! Referencing ABAP function modules implementation: CONVERT_TO_LOCAL_CURRENCY, CONVERT_TO_FOREIGN_CURRENCY Inherits SAP ERP decimal and rounding inaccuracy Inherits SAP ERP decimal shift problematic (e.g. Japanese Yen, Bahrain Dollar, …) Pre-requisites SAP ERP currency tables and configuration (TCUR* tables) Conversion is SAP Client dependent
© 2012 SAP AG. All rights reserved.
Public
57
SAP HANA Currency Conversion – Using CC with Measures 1. Define a calculated measure 4. Set the target currency: •
fixed value
•
target currency column
•
input parameter
3. Set the source amount column
5. Fill in all other conversion parameters: • source currency column • exchange type • conversion date column • Behavior on conversion failure © 2012 SAP AG. All rights reserved.
2. Set the default schema, where the SAP ERP TCUR*-tables are stored
Public
58
SAP HANA Analytical Privileges Analysis authorizations for HANA Information Models • Analysis authorizations for row-level security Can be based on attributes in analytic views • Analytic privilege is always a concrete implementation I.e. Specific authorization for specified values of given attribute you have to create privileges for each group of users or define dynamic analytic priviledges
© 2012 SAP AG. All rights reserved.
Public
59
Building SQL-Script-based Calculation Views
Modeling Custom Scenarios – SQL Script-based Calculation Views Scripts-based Calculation Views • Calculation Views are side affect free / READ-ONLY functions • Use of custom SQLScript to build Calculation Views Write SQLScript CE-functions or standard SQL-statements with raw tables or modeled views (preferred) Define output structure, activation creates column store based on Script Output Semantic Node
© 2012 SAP AG. All rights reserved.
Public
61
Modeling Custom Scenarios – SQL Script-based Calculation Views Scripts-based Calculation Views • Use of custom SQLScript to build Calculation Views Calculation Engine functions should not be mixed with standard SQL statements Client queries can be well optimized and parallelized by the CE engine Usually much better performance results than calculation view via standard SQL
Preferred • Parallel query execution • Only selected fields will be fetched
© 2012 SAP AG. All rights reserved.
Public
62
Excursus SQLScript – Standard SQL and CE-functions SQL
CE function
SELECT on column table
out = SELECT A, B, C from "COLUMN_TABLE"
out = CE_COLUMN_TABLE("COLUMN_TABLE", [A, B, C])
SELECT on attribute view
out = SELECT A, B, C from "ATTRIBUTE_VIEW"
out = CE_JOIN_VIEW("ATTRIBUTE_VIEW", [A, B, C])
SELECT on analytic view
out = SELECT A, B, C, SUM(D) from "ANALYTIC_VIEW" GROUP BY A, B, C
out = CE_OLAP_VIEW("ANALYTIC_VIEW", [A, B, C]);
WHERE HAVING
out = SELECT A, B, C, SUM(D) from "ANALYTIC_VIEW" WHERE B = 'value' AND C = 'value'
col_tab= CE_COLUMN_TABLE("COLUMN_TABLE"); out = CE_PROJECTION(col_tab, [A, B, C], ' "B" = ''value'' AND "C" = ''value'' ');
GROUP BY
out = SELECT A, B, C, SUM(D) FROM"COLUMN_TABLE" GROUP BY A, B, C
col_tab= CE_COLUMN_TABLE("COLUMN_TABLE"); out = CE_AGGREGATION( (col_tab, SUM(D), [A, B, C]);
INNER JOIN
out = SELECT A, B, Y, SUM(D) from "COLTAB1" INNER JOIN "COLTAB2" WHERE "COLTAB1"."KEY1" = "COLTAB2"."KEY1" AND "COLTAB1"."KEY2" = "COLTAB2"."KEY2"
out = CE_JOIN("COLTAB1","COLTAB2", [KEY1, KEY2], [A, B, Y, D])
LEFT OUTER JOIN
out = SELECT A, B, Y, SUM(D) from "COLTAB1" LEFT OUTER JOIN "COLTAB2" WHERE "COLTAB1"."KEY1" = "COLTAB2"."KEY1" AND "COLTAB1"."KEY2" = "COLTAB2"."KEY2"
out = CE_LEFT_OUTER_JOIN("COLTAB1","COLTAB2", [KEY1, KEY2], [A, B, Y, D])
SQL Expressions
out = SELECT A, B, C, SUBSTRING(D,2,5) FROM "COLUMN_TABLE"
proj_tab = CE_COLUMN_TABLE("COLUMN_TABLE"); out = CE_PROJECTION( :proj_tab, ["A", "B", "C", CE_CALC('midstr("D",2,5)', string) ]);
UNION ALL
col_tab1 = SELECT A, B, C, D FROM "COLUMN_TABLE1"; col_tab2 = SELECT A, B, C, D FROM "COLUMN_TABLE2"; out = SELECT * FROM :col_tab1 UNION ALL SELECT * FROM :col_tab2;
col_tab1 = CE_COLUMN_TABLE("COLUMN_TABLE1",[A,B,C,D]); col_tab2 = CE_COLUMN_TABLE("COLUMN_TABLE2",[A,B,C,D]); out = CE_UNION_ALL(:col_tab1,:col_tab2);
© 2012 SAP AG. All rights reserved.
Public
63
Modeling Custom Scenarios – SQL Script-based Calculation Views Scripts-based Calculation Views • Invoke and consume other functions from within Script-based calculation Stored Procedures built in CE or generic SQL Read-only / Read-write procedures can be created IN (Input) parameters can be of scalar or table type OUT (Output) parameters must be of table type Tables types required are generated automatically
Stored Procedure
Invoke via Procedure CALL
© 2012 SAP AG. All rights reserved.
Public
64
General Modeling Principles
SAP HANA General Modeling Principles Client / Application
Avoid transfer data of large resultsets between the HANA DB and client application A
G
Y
- Do calculation after aggregation.
Z
- Avoid Complex expressions (IF, CASE, ... )
Calculation Views
Attribute Views
Analytical Views
Reduce data transfer between views A
G
Y
A
B
C
Aggregate data records (e.g using GROUP BY, reducing Coulmns)
D
G
Y
Join on Key Columns or Indexed Columns Avoid calculations before aggregation on line item level
A
Column Store © 2012 SAP AG. All rights reserved.
B
C
D
Filter data amount as early as possible in the lower layers (CONSTRAINTS, WHERE Clause, Analytical Privileges..) Public
66
Disclaimer This presentation outlines our general product direction and should not be relied on in making a purchase decision. This presentation is not subject to your license agreement or any other agreement with SAP. SAP has no obligation to pursue any course of business outlined in this presentation or to develop or release any functionality mentioned in this presentation. This presentation and SAP’s strategy and possible future developments are subject to change and may be changed by SAP at any time for any reason without notice. This document is provided without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP assumes no responsibility for errors or omissions in this document, except if such damages were caused by SAP intentionally or grossly negligent.
© 2012 SAP AG. All rights reserved.
Public
67
Thank you Contact information Christoph Morgen SAP HANA Product Management
[email protected] To get the best overview of what’s new in SAP HANA SPS 07, read this blog.
© 2013 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. National product specifications may vary. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty. SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries. Please see http://www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional trademark information and notices.
© 2012 SAP AG. All rights reserved.
Public
69