Вы находитесь на странице: 1из 129

SAP HANA

SAP HANA Introduction

WHAT is SAP HANA ????

SAP HANA is an In-Memory Database

WHAT is SAP HANA ????

SAP HANA is an Appliance

SAP HANA appliance is a flexible, multipurpose, data-source-agonistic in-memory


appliance that combines SAP software
components optimized to run on Intel-based
hardware delivered by SAPs leading
partners such as Dell, Cisco, IBM, HP, and
Fujitsu.
It includes a number of integrated SAP
software components including the SAP
HANA database, real-time replication
services, data services, data and lifecycle
management, support for multiple interfaces
based on industry standards and easy to use
data modelling tool called SAP HANA studio.

WHAT is SAP HANA ????

SAP HANA is a Platform:

SAP HANA has its own Application Server (XS) only available from SP 5

XS stands for :
Extra Small
Extended Application Services

XS is a small-footprint application server, web server, and basis for an application development
platform - that livesinside SAP HANA.

WHAT is SAP HANA ????

SAP HANA Cloud

We can install SAP HANA on-premises or Cloud

SAP One SAP HANA Platform on Cloud

SAP HANA

What Makes SAP HANA So Fast ????????

What Makes SAP HANA Fast?

Multicore Processing

1 Server Board 8 CPUs (Intel Xeon CPUs)

1 CPU upto 12 Cores

Row Store & Column Store

10

Row Store & Column Store

11

Row Store v/s Column Store

12

Column Store

13

Push Data Intensive Logic into SAP HANA

14

Partioning

15

SAP HANA Architecture .

16

Index Server

17

SAP HANA Components

18

SAP Hana Software Specifications

19

How can we use SAP HANA ???

SAP HANA Use Cases

SAP HANA as Data Mart


SAP HANA as database
SAP HANA as Accelerator
Cloud on HANA
Mixed Approach ( SAP HANA as Data Mart + Database )
SAP Hana Development New APPS

Native Apps
Non-Native Apps

20

SAP HANA as Data Mart


SAP Business
Objects

Third Party
Tools

MDX , SQL, BICS

SAP
Business
Suit

BODS
SLT
DXC
Smart Data Access

SAP HANA

SAP BW

Non
SAP
Systems

BODS, Smart Data Access, SLT

21

SAP HANA as Database

OLTP

OLAP

SAP BW >
7.3 SP 5
SAP HANA

SAP HANA
SAP ECC

SAP BW

SAP ECC

SAP HANA

SAP HANA

22

SAP HANA As Accelerator

SAP ECC

Non HANA
DB

Secondary Database for reporting

SLT

HANA DB

23

Course Contents

24

Introduction to HANA Studio

25

SAP HANA Studio

SAP HANA Studio Walk Through on System

26

DATABASE Artifacts

SAP HANA Database Artifacts

27

DATABASE Artifacts

Schema
Database Table

Row Store

Column Store
Synonyms
Database View
Sequence
Triggers
Indexes
Functions
Column Views
Procedures

28

Schema

Schema :

Schema is place where we can store HANA Database Objects.


CREATE SCHEMA <Schema Name>;
DROP SCHEMA <Schema Name>;
Note: By default the schema will be owned by user who creates schema.
CREATE SCHEMA <Schema Name> OWNED BY <User Name>;
Note: For every user we create in SAP HANA, a schema is created with same name.
Default / System Schemas:
_SYS_BIC, _SYS_BI, _SYS_STATISTICS,SYS, _SYS_REPO,_SYS_TASK.

29

Database Table

Database Table:
Set of Rows and Columns

Goto Slide 10

2 types of Database tables :

Row Store

Column Store

Create Database table using UI


Create Database table using SQL Editor

30

Synonyms

Synonyms:

Alias Table Names

CREATE SYNONYM <Schema Name.Synonym Name> FOR <Schema Name.Tanble Name>;

Public Synonym:
Provide unrestricted access to all users.
CREATE SYNONYM <Synonym Name> FOR <Schema Name.Tanble Name>;

31

Database View

Database View:
Join data from multiple database tables.

How to create Database View using UI


Create Database View with SQL
CREATE VIEW <Schema Name . View Name> AS
SELECT

32

Sequence

Sequence:
Similar to number range buffer

Create Sequence using UI


Create Sequence using SQL Editor

CREATE SEQUENCE <Schema Name.Sequence> START WITH 1.

33

Triggers

Trigger:
Use to trigger certain action after a particular transaction.

CREATE TRIGGER <Schema Name.Trigger Name>


AFTER INSERT ON <Schema Name.Table> FOR EACH ROW
BEGIN
CURRENT_TIMESTAMP
CURRENT_USER
END;

34

INDEXES

Indexes:

Indexes are to speedup the read operation from the table.


2 types of Index
Normal Index
FULLTEXT Index (Enabling Search for Unstructured data)

Create indexes in 2 ways


SQL Editor
UI
CREATE FULLTEXT INDEX <index Name> ON <Schema Name.Table.Column Name> TEXT
ANALYSIS ON;

35

Table User Defined Functions

Table User Defined Fucntions:

Table UDFs are read-only user-defined functions which accept multiple input parameters
and return exactly one results table.
SQLScript is the only language which is supported for table UDFs.

Create the Table UDF with SQL Script

CREATE FUNCTION <Schema Name .Function Name>(<Input Parameters>)


RETURNS table (<Output table Columns>)
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER AS
BEGIN
RETURN <Logic>
END;

36

Procedures

Procedures:

Similar to Function modules in Netweaver ABAP.


Implement re-usable code.
Built with SQLSCRIPT,R,L

CREATE PROCEDURE "HANA"."PROCEDURE1" ( IN B INTEGER, IN C INTEGER, OUT A INTEGER)


LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER AS
BEGIN
A := B + C;
END;

37

Column Views

These Views are generated when we activate Information Views.

38

SQL Basics

SQL Basics

SQL Structured Query Language. SQL is used to communicate with a database.

According to ANSI (American National Standards Institute), it is the standard language for
relational database management systems.

SQL is used to retrieve, store or manipulate information in the database.

SQL statements perform the following tasks:

Schema definition and manipulation


Data manipulation
System management
Session management
Transaction management

39

SQL

1. Viewing Tables
2. Select & From
3. Where Clauses
4. Functions
5. Group By
6. Order By
7. Having
8. Top
9. Create
10. Insert
11. Update
12. Delete
13. Joins
14. Sub Selects
15. Unions
16. Drop
17. Views
18. Schemas
19. Table Types
20. Procedures

40

Schema

Schema :
Schema is place where we can store HANA Database Objects.

CREATE SCHEMA <Schema Name>;


DROP SCHEMA <Schema Name>;
Note: By default the schema will be owned by user who creates schema.
CREATE SCHEMA <Schema Name> OWNED BY <User Name>;
Note: For every user we create in SAP HANA, a schema is created with same name.
Show creating schema by creating user.
Default / System Schemas:
_SYS_BIC, _SYS_BI, _SYS_STATISTICS,SYS, _SYS_REPO,_SYS_TASK.

41

CREATE

Get the CREATE statement from Table definition Export SQL

From Scratch

CREATE COLUMN TABLE <Schema Name. Table Name>


( <Column List Data Type)

42

ALTER

ALTER TABLE "BATCH1"."MYROW" ALTER TYPE COLUMN;

ALTER TABLE "BATCH1"."MYROW" ADD (COUNTRY VARCHAR(20));

ALTER TABLE "BATCH1"."MYROW" ALTER (COUNTRY INTEGER);

43

VIEWING TABLES

Data Preview Option Context menu of the Database Tables.

View Log.

44

TABLE TYPES

Row Store
Column Store
Table Type

Converting Row Store table to Column Store.

ALTER TABLE <Schema Name.Table Name> ALTER TYPE COLUMN;

CREATE TYPE <Schema Name.Table type name> as table ( <Column list with data type> );

45

SELECT & FROM CLAUSES

SELECT <COLUMN1, COLUMN2 . OR *> FROM <Schema Name.Table>;

Rename Columns by using AS

How to get the Select Statement from LOG of Open Data Preview

46

WHERE CLAUSES

=
LIKE WILDCARDS %
BETWEEN AND

Combine Where Clauses with AND

IN Operator (value1, value2, )

OR

47

ORDER BY

Sorting Asc or Dsec


Default Asc.
Multiple Columns
Order Columns provide list in SELECT.

48

FUNCTIONS

Can be used to summarize and perform calculations on the data.

COUNT()
SUM()
*
MIN()
MAX()
AVG()
ROUND(,2)

49

GROUP BY

when we use Aggregation function.


Used when we apply a function in an select statement.

50

HAVING

Where Clause on the Aggregated function Columns

Where sum(netsales) > 500000;

HAVING CLAUSE has to be place before ORDER BY.

SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY

51

TOP CLAUSE

TOP 5 OR .

ORDER BY Aggregated Coulumns

SELECT TOP N

52

SUBSELECTS

Output of one query act as input / condition on another query.

Ex:- Average Netsales.

53

INSERT

Generate Insert Statement from context menu of the Table.

From Scratch
INSERT INTO <Schema Name.Table Name> values (,,.);

Multiple Rows

54

UPDATE
UPDATE <Schema Name.Table Name>
SET <Column Name> = <Value>
WHERE <Condition>;

Multiple Rows

55

DELETE
DELETE FROM <Schema Name.Table Name>
Where <Condition>;

Multiple Rows.

Delete the table contents using UI

56

JOINS

Use the Database View UI to generate the SQL.

SELECT
FROM
WHERE

57

UINIONS

UNION (No Duplicates)


UNION ALL (Including Duplicates)

Ex:- Combine list of customers.

58

DROP

Delete tables using UI


Cascade / Restric

Create Duplicate table and play on it.

Use TRUNCATE statement for deleting data in table similar to DELETE.

DROP TABLE <Schema Name.Table Name> CASCADE / RESTRICT;

59

Stored Procedures

Similar to Function Modules in ABAP.


We use SQLSCRIPT language
We can also use R,L
We can also use CE-Functions
This can have Import & Output parameters
We can create stored procedures in Catalog , Content or HANA Development

SYNTAX:

CREATE PROCEDURE <Schema Name.Procedure Name> (


IN or OUT parameters
)
LANGUAGE SQLSCRIPT
SQL SECURITY DEFINER
DEFAULT SCHEMA _SYS_BIC
READS SQL DATA AS

BEGIN

END;

60

Stored Procedures

Demo Examples

61

Stored Procedures

CE-Fucntions:

Refer to SQL Reference Guide.

62

CE Functions

63

CE Functions

64

CE Functions

65

CE Functions

66

Stored Procedures

Demo on CE-Functions.

67

SAP HANA

SAP HANA Modelling

68

SAP HANA Modelling

INDEX

Introduction to Modelling
Packages
Attributes & Measures
Information Views
Attribute View
Analytic View
Calculation View
SQL Script Based
Graphical Mode
Analytical Privileges
Stored Procedures
Decision Tables

69

Introduction to Modelling

Modeling refers to an activity of refining or slicing data in database tables by creating views to
depict a business scenario. The views can be used for reporting and decision making.

The modeling process involves the simulation of entities, such as customer, product, and sales,
and the relationships between them.

70

Introduction to Modelling

Attribute: Descriptive data, such as customer ID, city, and country.

Measure: Quantifiable data, such as revenue, quantity sold and counters.

71

Introduction to Modelling

You can model entities in SAP HANA


using the Modeler perspective,

72

Introduction to Modelling

You can create the following


types of information views:

Attribute Views

Analytic Views

Calculation Views

73

Introduction to Modelling

SAP HANA Modeler perspective supports the below object types:

Attribute View:
Similar to Master data in SAP BW
Similar to Dimension in SAP BO
Analytic View:
Similar to Infocube in SAP BW
Similar to Facttable in SAP BO
Calculation View:
Graphical Mode : Similar to Multiprovider or Infoset in SAP BW
SQL Script : Similar to Virtual Infocube based on function Module
Analytical Privileges:
Similar to Analysis Authorizations in SAP BW
Decision Tables:
Business Rules for Transformations.
Can be used for What if Analysis.

74

Introduction to Modelling

Walkthrough on HANA Studio : Modeler Perspective

75

Introduction to Modelling

Modelling Process:

76

Packages

In SAP HANA Modelling Objects are organized by using PACKAGE.


Similar to InfoArea in SAP BW

77

Attributes & Measures


Attribute: Descriptive data, such as customer ID, city, and country.

Types Of Attributes
Simple Attributes
Calculated Attributes
Local Attributes

78

Attributes & Measures


Measure: Quantifiable data, such as revenue, quantity sold and counters.

Types Of Measures
Simple Measures
Calculated Measures
Restricted Measures
Counters

79

Attribute View

Attribute View:

Similar to Master data in SAP BW

Similar to Dimension in SAP BO

Attribute views are used to model an entity based on the relationships between attribute data
contained in multiple source tables.

Once attribute view is created it can be


joined to a fact table via an analytic view to
provide meaning to its data. The attribute
view is shown as a single dimension table.

You can create hierarchies to arrange the


attributes hierarchically.

You can create Level hierarchies and Parent


Child hierarchies

Types Of Attribute Views

Standard

Time
Derived

80

Attribute View

Standard:

Time:
1. You have imported SAP system tables T009 and T009B tables for creating an attribute
view whose type is Time.
2. Auto generation for Time Attribute view - we use GENERATE TIME DATA
3. In case of Gregorian Calendar
The system populates the generated time data in M_TIME_DIMENSION_YEAR,
M_TIME_DIMENSION_MONTH, M_TIME_DIMENSION_WEEK, M_TIME_DIMENSION
tables in _SYS_BI schema.
4. In Case of Fiscal Year Calendar:

The system populates the generated time data in the M_FISCAL_CALENDAR


table, which is located in the _SYS_BI schema.

Derived: Reference object - only Description can be changed.

81

82

83

84

85

86

Data Category : Dimension indicates that this view cannot include MEASURES in it.

Type : This property indicates the Type of Attribute View.

Base Attribute View: Shows the Base attribute view on which the Attribute view has been
derived. This is shown only incase of DERIVED ATTRIBUTE VIEW.

Analytical Privileges: To enable Analytical Privileges Yes or No on top of this view.

Default Client : Uses MANDT field in the tables.


User specific client as session client

87

Generate Concat Attributes:


This Option is used when we join tables on 2 or more columns.
It creates an extra column in the base database table which stores the
concatenated values of both the columns to speed up the join.
We have to be careful on this option as enabling this option will occupy
extra space in the database.
Use an database view (M_CS_ALL_COLUMNS) in SYS schema to view the
new columns added in database table.

Enable History:
Is used to enable time travel queries by using history tables.

Cache Invalidation Period:


A time-based cache invalidation property (advanced view properties), which
sets the time interval, when cached results shall be invalidated or removed from
the query cache

88

Steps Creating Attribute View:

1. Add all the required tables into Data Foundation Node.

2. If multiple tables used in Data Foundation establish Joins on the tables

3. Select the required fields from the tables in Data Foundation.

4. If required create Calculated Columns. (only attributes ) Measures are not allowed in
Attribute Views.

5. Adjust the Fields properties as per the requirement.

6. If required Apply Filters to restrict the data for the View (Similar to Where Clause )

Note:- Filtering can be made dynamic by using Input Parameters and map them with input
parameters in Analytical View or Calculation View

7. In semantics Node, Define the Key field (Mandatory Step).

8. In Semantics Node, If Required Define Semantics for the columns / fields selected from data
foundation

9. If Required define Hierarchies in semantics node.

89

Calculated Column

90

Hierarchies

91

Attribute View

Pre-Requisites to consume database tables from any schema while creating Information Views:

GRANT SELECT ACCESS ON SCHEMA TO _SYS_REPO USER

Syntax:

GRANT SELECT ON <SCHEMA NAME> TO _SYS_REPO WITH GRANT OPTION;

92

Attribute View

Demo on Attribute View

93

Hierarchies in Depth

94

2 types of Hierarchies:
Level Based Hierarchy

Parent-Child Hierarchy

95

Level Hierarchy:

To create a hierarchy that is rigid in nature such that, the root and
child nodes can be accessed only in the defined order. In a level
hierarchy you define several levels which point to the view
attributes.

Root Node

ALL

Country
States

IN

AP

US

TG

DALLAS

Chicago

96

Parent Child Hierarchy:

To create a hierarchy that is derived from the value of a node. The


hierarchy can be explored based on a selected parent; there are
also cases where the child can be a parent

Manager1

Employee 2

Employee 1
97

Level Based Hierarchy: [Node Style]

Level Name - the unique node ID is composed of the level name and node
name; for example, "[Level 2].[B2]".
Name Only - the unique node ID is composed of level name; for example, "B2".
Name Path - the unique node ID is composed of the result node name and the
names of all ancestors apart from the (single physical) root node; for example,
"[A1].[B2].[C3]".

98

Level Based Hierarchy: [Level Type]

The level type is used to specify the semantics for the level attributes.
A level of the type LEVEL_TYPE_TIME_MONTHS indicates that the attributes
of the level contain month such as "January", and LEVEL_TYPE_REGULAR
indicates that a level does not require any special formatting.
99

Level Based Hierarchy: [Order By & Sort Direction]

100

Level Based Hierarchy: [Aggregate ALL NODES]

FALSE:

TRUE:

Parent : A [100] -- [30]


Child : A1 [10]
Child : A2 [20]

Parent : A [100] [130]


Child : A1 [10]
Child : A2 [20]

101

Level Based Hierarchy: [Aggregate ALL NODES]

Default Node : [level2].[IN]

102

103

104

Attribute View

Points to be Noted:

1. Will not be able to include Measures in Attribute Views

2. Key Attribute is must (Primary Key Field)

3. We can have multiple Key Attributes in this case all the keys attributes must be referred
from same database table.

4. Joins: Text join, Referential Join, Inner Join, Left Outer Join, Right Outer Join

5. We can Filter the data in Attribute View

6. We can use Input parameter Place holders which can be mapped with Input parameters in
Analytical view or Calculation view.

7. We can create Hierarchies in Attribute View which can be leveraged in analytical views.

8. Assign Semantics

9. Alias Tables

105

Attribute View

10. Creates a Column View automatically in SYS_BIC schema.

11.Setting up the cardinality for the join

11 You have imported SAP system tables T009 and T009B tables for creating an attribute view
whose type is Time.

12. Auto generation for Time Attribute view - we use GENERATE TIME DATA
In case of Gregorian Calendar

The system populates the generated time data in M_TIME_DIMENSION_YEAR,


M_TIME_DIMENSION_MONTH, M_TIME_DIMENSION_WEEK, M_TIME_DIMENSION tables in
_SYS_BI schema.

In Case of Fiscal Year Calendar:

The system populates the generated time data in the M_FISCAL_CALENDAR table, which is
located in the _SYS_BI schema.

106

Analytic View
Analytic View:
Similar to Infocube in SAP BW
Similar to Facttable in SAP BO

Analytic views are used to model data that includes measures. For example, transactional fact
table representing sales order history would include measures for quantity, price, and so on.

Analytic views can contain two types of columns: attributes and measures. Measures are
simple, calculated or restricted. If analytic views are used in SQL statements, then the
measures have to be aggregated. For example, using the SQL functions SUM(<column
name>), MIN(<column name>), or MAX(<column name>). Normal columns can be handled as
regular attributes and do not need to be aggregated.

107

108

109

Data Foundation:

Alias Tables Can be Used.


In Analytical View Data Foundation we cannot edit the field
properties

110

Star Join:

111

Star Join:

112

Semantics : Columns

113

Semantics: View Properties

114

1825549 - Performance degradation for query on CalcView


https://websmp230.sapag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/sno/ui_entry/entry.htm?param=6976
5F6D6F64653D3030312669765F7361706E6F7465735F6E756D6265723D313
8323535343926
115

Semantics : Hierarchies

116

117

Analytic View

Demo on Analytic View

118

Analytic View

Points to be Noted:

When we activate Analytic view it creates COLUMN VIEWS in SYC_BIC Schema

Data Foundation can include multiple database tables but we can use measures only from one
table (Central Table).

Hierarchies cannot be created in Analytic view but we can use Hierarchies built in Attribute
views.

In Star Join, we can create Calculated columns (attributes or measures) and restricted
measures

We can create variables & Input Parameters in Analytical view (Mapping of Input Parameters)

In Star Join we can create Temporal Join (can not be created in Data Foundation)

Currency or Unit Conversion can be handled in Analytic view

Sematic Properties

Applying Filters

Measures grouped in Folder

119

Calculation View

Create calculation views to provides composites of other views. You can classify calculation
views as script-based calculation view or graphical calculation view

They can be used in the same way as analytic views; however, in contrast to analytic views, it
is possible to join several fact tables in a calculation view.

Set to Cube - if you want to define a calculation view that is visible in the multidimensional
reporting tools.

Set to Dimension - The view is not available for multidimensional reporting and is only
consumable via SQL.

Calculation views can include measures and be used for multidimensional reporting or can
contain no measures and used for list-type reporting.

2 ways Graphical Mode & SQL Script based

Use Calculation view to implement complex scenarios

We can use Attribute View, Analytical View, Database Tables , Column Views in creating
Calculation view.

Graphical Mode:

We can use Nodes like Union, Join, Aggregation, ProjectioN,Rank

120

We can create Hierarchies in calculation views.

121

122

123

Calculation View

Demo Graphical Calculation View

Demo SQLScript / CE Functions based Calculation View

124

Calculation View

Points to be Noted:

We can create calculation view Graphical mode or Script based.


Graphical calculation views can include layers of calculation logic.
We can use the Script based Calculation View as table Function in Graphical Calculation View.
We can also migrate Script based calculation view as Graphical Calculation View.
Following Nodes can be used in Graphical Calculation View: Join, Union, Projection,
Aggregation, Rank, Star Join.
The following Objects can be used as DataSources : Column Table, Column View, Attribute
Views, Analytical Views, Table Functions generated from Script based Calculation view.
Similar to attribute view or Analytical view, when a calculation view is activated it creates
column view in _SYS_BIC schema.
We can create 2 SUB types of calculation views: Standard , Time.
You can only have one source of input for RANK,aggregation and projection view nodes, and
two inputs for a join and union node (Multiple).
We can create hierarchies in Calculation View.
Aggregation node keep Flag property
Optimize join Join node
Dynamic Join Join node
Calculation Views of data category Dimension & BLANk cannot be used for reporting directly.

125

In Graphical Calculation View Filtering can be applied only on Aggregation Nodes & Projection
Nodes which are not default.

Propagate to semantics.

Generate Concat Attributes

Execute in SQL

Transparent Filter

Extract Semantics

Restricted Column with Input Parameter

Mapping of Variables & Input Parameters

Enable History Time Travel Queries

126

Analytical Privileges

Similar to Authorization Object in SAP BW.

Demo Analytical Privileges.

127

Decision Tables

Used to Transform the data.


ETL for Business Users.
What if Analysis.
Can update tables or only simulate.

Demo Decision Tables.

128

Data Provisioning

Import from flat Files


SLT
DXC
BODS
Smart Data Access.

129

Вам также может понравиться