Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Used with permission of SAP SE

Lesson: Levels of Modeling

Lesson Overview
This lesson looks at the different levels of information models in SAP HANA.

Lesson Objectives
After completing this lesson, you will be able to:
• Describe the levels of modeling in SAP HANA
• Create and display data for an Attribute View
• Create and display data for Analytical View
• Create and display data for an Calculation View

Business Example
You have an understanding about the data you want to create reports on, and you
have decided to create Information Models to base the reports on.

Figure 1: Modeling Process Flow

The diagram depicts the process flow for modeling within SAP HANA.
This example focuses on the process of creating Information Models and also
demonstrates how to export these models for easy portability.

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 3


HA100

Figure 2: Overview of Information Models (1)

Figure 3: Overview of Information Models (2)

4 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 4: Overview of Information Models (3)

Figure 5: Exercise Case Study

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 5


HA100

Attribute Views Overview

Figure 6: Attribute Views Overview

Figure 7: Attribute View

6 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 8: Creating a New Attribute View

1. Set Attribute View parameters


• Assign a unique name to the model.
– Allowed characters: capital letters (A-Z) and numbers (0-9), plus
underscore _
• Enter a short description for the view
– No multi-language support for such metadata → typically best choice
is using English text
• Select standard as the type of Attribute View
– A Time view creates a master data view for time characteristics
(calender year, quarter, month, week, day, fiscal year/period, ... with
different notations and so on.
• Identify if this will be a new or copied from
• Determine which package will hold the model

Note: When using the copied from option, models can be selected from
any package. One is not limited to only models within the selected
package. Packages simply organize Information Models similar to how
schemas organize physical tables.

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 7


HA100

Figure 9: Attribute View – Select Table(s)

2. Select tables

Note: Tables can be selected from multiple schemas and are not limited
to one schema per Attribute View.

8 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 10: Attribute View – Add Additional Table

When looking for a table from a schema containing many tables, you want to first
filter the list of tables in the schema:
• Right click the “tables” folder within the schema
• Enter a filter string
Note:
The filter string here must be the beginning of the table name.

• Click OK
• The list of tables in the schema is now filtered.
• Expand the “tables” folder to display the filtered list of tables.
• Now you can simply drag a table from the schema into your view.
This is a useful option if you have already found a table you need and for example
have displayed the table definition to make sure its the correct table.

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 9


HA100

Figure 11: Attribute View – Define Join Properties

3. Define join conditions

Figure 12: Joins

Inner Join:
• The INNER JOIN combines records from the left and right table exactly
when the specified criteria are met. If the criteria are not met, no record
is created in the result set.

10 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Left Outer:
• A record from the left table is always stored in the result set. If a record
from the right table met the criteria, it is combined to the record from the
left table, otherwise the columns are empty (zero).
Right Outer:
• A record from the right table is always stored in the result set. If a record
from the left table met the criteria, it is combined to the record from the right
table, otherwise the columns are empty (zero).
Text Join:
• Used to join a text table to a master data table. This is a requirement for
description mapping. The text join always filters on one language and thus
one needs to specify a language column in the text table. The language is
filtered based on the view settings (which are per default taken from the
user profile of the modeler)
Referential Join:
• Is semantically a inner join that assume that referential integrity is given
which means that the left table always have an corresponding entry on the
right table.
• It could be used in e.g. data foundation for header-item relations where it can
be assumed that for each item a header exists. It can be seen as an optimized
or faster inner join where the right table is not checked if no field from the
right table is requested.
• Referential Joins will be only executed, when fields from both tables are
requested. Therefore, if a field is selected from the right table it will act
similar to inner join, and if no fields from the right table is selected it will act
similar to a left outer join.
• Referential joints should be used with caution since it assumes that referential
integrity is ensured.

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 11


HA100

Figure 13: Attribute View – Output Field Selection and Filters

4. Select key attributes, attributes, and set filters as needed.

Figure 14: Attribute View – Set Description Mapping

12 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure : Map Texts

5. Define Description Mappings


• Description mapping is a technique to consistently connect the description
(text) to the semantic key of an attribute value.

Figure 1: Attribute Properties – Property Hierarchy Active – See Non-Key


Fields via MDX

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 13


HA100

If views are displayed via Excel, each Attribute view is represented in Excel as
a Dimension.
In our example, we have modelled the “Product dimension” with attributes
“Product Number” and “Product Category”.
• Product Number is the key
• Product Category is a non-key attribute
Each attribute in the list of output fields has among its properties a setting
“Hierarchy Active”. This setting defaults to “false”. If set to “false” the attribute
will only show up in Excel (via MDX) if it is a key field of the attribute view.
If set to “true”, the attribute will show up in Excel also if it is not a key field.

Figure 17: Attribute View – Define a Level Hierarchy

6. Create Hierarchies (level hierarchies)

Note: At present, hierarchies defined in the modeler are only accessible


via MDX.

14 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 2: Attribute View – Define a Parent-Child Hierarchy

6. Create Hierarchies (parent child hierarchies)

Note: At present, hierarchies defined in the modeler are only accessible


via MDX.

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 15


HA100

Figure 19: Attribute View – Calculated Attributes

Figure 20: Attribute View – Save and Activate the View

1 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 21: Save and Activate

Before a view is visible for reporting, it needs to be activated (deployed). The


activation process translates the metadata defined in the Information Model into
a database object.
A modified version of a view cannot be activated; one always needs to save the
view first. There is no implicit save performed when a user tries to activate a
modified view. It is not necessary to close the modeling editor.
Once view activation is finished, one can see the log of this activation process
(button in top-right corner of the Deployment Log view). This activation log
contains among other things the SQL call that has been executed in order to
create the views database object. This SQL call can be a good starting point for
issue analysis with views. The Deployment Log is also useful if there is an error
during view activation.
At this point we have deployed for consumption an Attribute View. This enables
reporting against this attribute view and allows including this view in analytic
views.

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 17


HA100

Figure 22: Attribute View – Preview the View

The data preview functionality is useful for confirming that one has modeled
the data the way he/she intended. It can be done at the Attribute view, or at the
physical tables at the foundation level.
There are three main views one can select from when previewing data:
• Raw Data – table format of data
• Distinct Values – graphical and text format identifying unique values
• Analysis – select fields (attributes and measures) to display in graphical
format
Reporting at this level will not include measures as measures are in Analytic
Views not Attribute Views. To conduct analysis on measures according to the
attributes in this Attribute View one would include this Attribute View in an
Analytic View definition.

2 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 23: Attribute View – Time Dimension Attribute Views (1)

Figure 24: Attribute View – Time Dimension Attribute Views (2)


Analytic Views

Figure 25: Analytical View are the Multidimensional Views that Analyze
Values from Single Fact Table

Figure 26: Analytic View

20 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 27: Analytic View – View Creation Wizard

1. Set Analytic View parameters


• Assign a unique name to the model.
• Ensure the View Type is Analytic View

Figure 28: Analytic View – Select Table(s)

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 21


HA100

The analytic view editor helps you to create a fact table by adding and joining the
tables in the Data Foundation node. In addition you can join attribute views to
these tables in the Logical Join node. You use Output view to model various
view elements: Columns, Calculated Columns, Restricted columns and Input
Parameters. In the Semantics node you can classify these 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.
2. Select tables

Figure 29: Analytic View – Select Attribute View(s)

3. Select Attribute Views (optional)


• Attribute Views can be added to the Logical Join

22 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 30: Analytic View – Analytic View Editor

4. Join Attribute Views


• The Data Foundation view shows the physical table with all fields that can be
incorporated in to the final model.
• The Logical Join view displays only those fields which you have chosen to
include in this model as well as the restricted and calculated measures that
have been defined.

Figure 224: Analytic View – Define the Data Foundation

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 23


HA100

5. Select the columns and set filters.

Figure 31: Analytic View – Join Attribute Views to Data Foundation

Define join conditions and cardinality. The default settings are “Referential join”
and “n:1”.
Click on the properties tab on the lower section of the screen to change these
settings if necessary.

24 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 32: Analytic View – Defining Calculated Columns

6. Create Calculated Columns

Figure 33: Analytic View – Defining Restricted Columns

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 25


HA100

7. Create Restricted Measures

Figure 34: Analytic View – Save and Activate the View

Figure 35: Semantic View

8. Save and Activate


The Analytic View can be validated, saved and activated as shown in the slide.
When saving, just the metadata of the model is saved but this cannot be viewed
from the reporting tools like SAP BusinessObjects.
Once activated it creates a column view (database view) in schema _SYS_BIC

26 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 36: Analytic View – Preview Data of Analytic View

The data preview functionality can be used for verification of the designed model.
It has three tabs:
• Raw Data – table format of data
• Distinct Values – graphical and text format identifying unique values
• Analysis – select fields (attributes and measures) to display in graphical
format.

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 27


HA100

Figure 37: Analytic View

Figure 38: Analytic View

You can display the data in a table format or a graph. There are multiple graphs
types available.

28 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 39: EXERCISE – Creating Analytic Views for the CO-PA Scenario
Calculation Views

Figure 40: Calculation View

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 29


HA100

Figure 41: Two Types of Calculation Views

Figure 42: Calculation View (Graphical)

30 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 43: Calculation View (Graphical) – View Creation Wizard (1)

Figure 44: Calculation View (Graphical) – Adding Nodes

This editor helps you to build view logic graphically using the tools available in
the Designer view for join, union, projection and aggregation operations. You can
perform these operations on data sources and/or on top of other operations. In the
Details view, you define the output of the selected nodes. You use the Output

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 31


HA100

view to model various view elements: attributes, calculated attributes, measures,


calculated measures, hierarchies, counters, variables, and input parameters.
Following is a summary of the different types of nodes

View Description Description


Union Used to combine the result set of two or more data
sources. For example, to know the names of all
the employees of a store with different branches
maintaining their own employee records table.
Join Used to query data from two or more data sources,
based on some condition. For example, to retrieve the
sales of two stores maintaining individual table for sales
based on the customer id.
Projection Used to filter or create a subset of the required columns
of a table or view for creating the model. For example,
selecting the employee name and sales quantity from a
table consisting of many more columns.
Aggregation Used to summarize data of a group of rows by
calculating values in a column. For example, to retrieve
total sales of some product in a month. The supported
aggregation types are sum, min, and max.

Figure 45: Calculation View (Graphical) – Output Node

32 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 46: Calculation View (Graphical)

It is possible to create complex expressions to calculate columns.


Example Expression: midstr(string(“ERDAT”),strlen(string(“ERDAT”))-9,4

Figure 47: Calculation View (Graphical)

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 33


HA100

Figure 48: Calculation View (Graphical)

Figure 49: Calculation View (Scripting)

34 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 50: Calculation Views – SQL Script Introduction

• Applications only offload very limited functionality into the database using
SQL, most of the application logic is normally executed in an application
server. SQLScript can be used to push data-intensive application logic into
the database.
• This has the effect that data to be operated upon needs to be copied from the
database into the application server and vice versa. When executing data
intensive logic, this copying of data is very expensive in terms of processor
and data transfer time.
• the SAP HANA database exposes a very sophisticated interface to the
application consisting of many languages. The expressiveness of these
languages far exceeds that attainable with OpenSQL.
Note: SQL Script is covered in more detail in course HA300.

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 35


HA100

Figure 51: Calculation View (Scripting) – Calculation View Wizard

36 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 52: Calculation View (Scripting) – Calc View Table Type

Hint: In order to get the correct data types from existing database tables,
one can
• Right-click the table in the navigator tree and
• Select Definition from the context menu; then
• Right-click into the editor that opens up (the tab displaying the list
of table fields) and
• Select Export SQL from the context menu

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 38


HA100

Figure 53: Calculation View (Scripting) – Function Definition

Figure 55: Calculation View (Scripting) – Add the SQL Script Code

39 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels of Modeling

Figure 56: Calculation View (Scripting) – Creating Run-Time Objects

Figure 57: Calculation View (Scripting) – Calc View Output Structure

2013 © 2013 SAP AG or an SAP affiliate company. All rights reserved. 40


HA100

Figure 58: Calculation View (Scripting) – Save and Activate

Figure 59: Recommendations – How to Build Content

41 © 2013 SAP AG or an SAP affiliate company. All rights reserved.


2013
HA100 Lesson: Levels
of Modeling

Figure 60: How to Build Content

Figure 61: Calculation View & SQL Script – When to Use


Copyright

Copyright © 2013 SAP AG or an SAP affiliate company. 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.

Trademarks

Adobe, the Adobe logo, Acrobat, PostScript, and Reader are trademarks or registered trademarks of Adobe Systems Incorporated
in the United States and other countries.
Apple, App Store, FaceTime, iBooks, iPad, iPhone, iPhoto, iPod, iTunes, Multi-Touch, Objective-C, Retina, Safari, Siri, and
Xcode are trademarks or registered trademarks of Apple Inc.
Bluetooth is a registered trademark of Bluetooth SIG Inc.
Citrix, ICA, Program Neighborhood, MetaFrame now XenApp, WinFrame, VideoFrame, and MultiWin are trademarks or
registered trademarks of Citrix Systems Inc.
Computop is a registered trademark of Computop Wirtschaftsinformatik GmbH.
Edgar Online is a registered trademark of EDGAR Online Inc., an R.R. Donnelley & Sons Company. Facebook, the Facebook and
F logo, FB, Face, Poke, Wall, and 32665 are trademarks of Facebook.
Google App Engine, Google Apps, Google Checkout, Google Data API, Google Maps, Google Mobile Ads, Google Mobile
Updater, Google Mobile, Google Store, Google Sync, Google Updater, Google Voice, Google Mail, Gmail, YouTube, Dalvik, and
Android are trademarks or registered trademarks of Google Inc.
HP is a registered trademark of the Hewlett-Packard Development Company L.P.
HTML, XML, XHTML, and W3C are trademarks, registered trademarks, or claimed as generic terms by the Massachusetts
Institute of Technology (MIT), European Research Consortium for Informatics and Mathematics (ERCIM), or Keio University.
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, z10, z/VM,
z/OS, OS/390, zEnterprise, PowerVM, Power Architecture, Power Systems, POWER7, POWER6+, POWER6, POWER,
PowerHA, pureScale, PowerPC, BladeCenter, System Storage, Storwize, XIV, GPFS, HACMP, RETAIN, DB2 Connect, RACF,
Redbooks,
OS/2, AIX, Intelligent Miner, WebSphere, Tivoli, Informix, and Smarter Planet are trademarks or registered trademarks of IBM
Corporation.
Microsoft, Windows, Excel, Outlook, PowerPoint, Silverlight, and Visual Studio are registered trademarks of Microsoft
Corporation.
INTERMEC is a registered trademark of Intermec Technologies Corporation. IOS is a registered trademark of Cisco Systems Inc.
The Klout name and logos are trademarks of Klout Inc.
Linux is the registered trademark of Linus Torvalds in the United States and other countries. Motorola is a registered trademark of
Motorola Trademark Holdings LLC.
Mozilla and Firefox and their logos are registered trademarks of the Mozilla Foundation. Novell and SUSE Linux Enterprise
Server are registered trademarks of Novell Inc.

You might also like