You are on page 1of 226

PUBLIC

SAP HANA Platform 2.0 SPS 04


Document Version: 1.1 – 2019-10-31

SAP HANA Modeling Guide


For SAP HANA XS Advanced Model
© 2019 SAP SE or an SAP affiliate company. All rights reserved.

THE BEST RUN


Content

1 SAP HANA Modeling Guide for XS Advanced Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2 Modeling Calculation Views in SAP Web IDE for SAP HANA. . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Creating a Graphical Calculation View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8


3.1 Attributes and Measures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 Create Graphical Calculation Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10
Create Graphical Calculation Views with Star Joins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Create Graphical Calculation Views with Time Dimension. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Create Virtual Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Supported View Nodes for Modeling Calculation Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Working With View Nodes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Supported Data Categories for Calculation Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Example: Using Keep Flag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92
3.3 Preview Calculation View Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

4 Working With Attributes and Measures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97


4.1 Create Counters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
4.2 Create Calculated Columns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
4.3 Create Restricted Columns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Example: Using Restricted Measures for Pivoting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
4.4 Assign Semantics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Extract and Copy Semantics From Underlying Data Sources. . . . . . . . . . . . . . . . . . . . . . . . . . 104
Propagate Columns to Semantics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Supported Semantic Types for Measures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Supported Semantic Types for Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
4.5 Assign Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Use Session Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109
Supported Variable Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Supported Session Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.6 Create Input Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Map Input Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Input Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
4.7 Using Hierarchies for Reporting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
Create Level Hierarchies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Create Parent-Child Hierarchies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123
Query Shared Hierarchies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Orphan Nodes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

SAP HANA Modeling Guide


2 PUBLIC Content
Root Node Visibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
4.8 Using Currency and Unit of Measure Conversions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129
Associate Measures with Currency. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Associate Measures with Unit of Measure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Reuse a Currency Conversion or Unit Conversion Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Tag Measures as Converted or Unconverted Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
4.9 ORDER BY and Sort the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
4.10 Mask Column Values in Client Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144
4.11 Assign Value Helps for Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
4.12 Enable or Disable Attributes for Drilldown in Reporting Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
4.13 Handle Null Values in Columns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
4.14 Set Presentation Scale for Measures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
4.15 Convert Attribute Values to Required Formats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
4.16 Associate Attributes with Other Related Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
4.17 Group Related Measures and Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

5 Working With Calculation View Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153


5.1 Filter Data for Specific Clients. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153
Default Client Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154
5.2 Enable Calculation Views for Time Travel Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
5.3 Invalidate Cached Content. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Enabling or Disabling Result Set Caching. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
5.4 Deprecate Calculation Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .157
5.5 Quick Reference: Calculation View Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158

6 Defining Data Access Privileges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161


6.1 Create Static SQL Analytic Privileges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
6.2 Create Dynamic SQL Analytic Privileges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
6.3 Create Analytic Privileges Using SQL Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165
6.4 Structure of SQL-Based Analytic Privileges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Examples: Securing Views Using SQL-Based Analytic Privileges. . . . . . . . . . . . . . . . . . . . . . . . 169

7 Additional Functionality for Calculation Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176


7.1 Add an External Service in the mta.yaml File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176
7.2 Trace Objects with Data Lineage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
7.3 Trace Dependent Objects to Analyze Impacts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
7.4 Performance Analysis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Open Calculation Views in Performance Analysis Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Debug Calculation Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182
7.5 Maintain Comments for Calculation View Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184
7.6 Replacing Nodes and Data Sources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186
Replace a View Node in Calculation Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

SAP HANA Modeling Guide


Content PUBLIC 3
Replace a Data Source in Calculation Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
7.7 Using Functions in Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .189
Using Column Engine Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .189
Using SQL Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
7.8 Manage Calculation Views with Missing Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
7.9 Rename and Refactor Calculation Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Rename and Refactor Output Columns and Input Parameters. . . . . . . . . . . . . . . . . . . . . . . . . 220
7.10 Generate Properties File for Calculation Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
7.11 Generate Calculation View Documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

8 Important Disclaimer for Features in SAP HANA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

SAP HANA Modeling Guide


4 PUBLIC Content
1 SAP HANA Modeling Guide for XS
Advanced Model

This guide explains how to model analytic data, for example, calculation view and analytic privileges in SAP
HANA Extended Application Services advanced model (XS advanced).

Related Information

Modeling Calculation Views in SAP Web IDE for SAP HANA [page 6]

SAP HANA Modeling Guide


SAP HANA Modeling Guide for XS Advanced Model PUBLIC 5
2 Modeling Calculation Views in SAP Web
IDE for SAP HANA

SAP Web IDE for SAP HANA is a comprehensive browser-based IDE for the development of complex
applications that can include web-based or mobile UIs, business logic, and extensive SAP HANA data models.

Designed to support developers who use SAP HANA and XS Advanced, SAP Web IDE provides various tools,
such as syntax-aware editors for code and SAP HANA artifacts, graphical editors for CDS data models and
calculation views, as well as inspection, testing, and debugging tools.

This guide describes two modeling scenarios that users can perform in the SAP Web IDE for SAP HANA. In the
first scenario, users can use the graphical editor in the SAP Web IDE to refine or slice data in database tables by
creating calculation views that depict a business scenario. You can use these calculation views for any
reporting and decision making purposes.

In the other scenario, you can use the graphical editor to create persistence models in core data services. The
persistence model defines the schema, tables, sequences, and views that specify what data to make available
for consumption by applications and how. In SAP Web IDE for SAP HANA, the persistence model is mapped to
the consumption model that is exposed to client applications and users, so that data can be analyzed and
displayed in the appropriate form in the client application interface.

Who should read this guide

This guide is intended for data modelers or business analysts or data analysts or application developers
building database models or database experts involved in the processes of defining data models and schemas,
database tables, information views, primary keys, indexes, partitions, and all other aspects of layout and
interrelationship of data in SAP HANA.

The database developer is also concerned with designing and defining authorization and access control,
through the specification of privileges, roles, and users.

Calculation View Instantiation Process

The Calculation Engine is designed for optimal performance and thus uses a variety of optimization processes.
The Calculation Engine optimizations can sometimes result in a nonrelational behavior. This means that it does
not behave in the same way a user familiar with SQL would expect. One of the reasons for nonrelational
behavior in the SAP HANA Calculation Engine is the instantiation process.

During an instantiation processes the Calculation Engine simplifies the calculation view into a model that fulfills
the requirement of the query. This means that, the Calculation Engine will prune a calculation view that has
Field_1 and Field_2 into a model that only consists of Field_1 if no other fields are requested by the query
executed on the calculation view. The other example of optimizations in calculation views is the pruning of
joins.

The calculation view instantiation happens at runtime when executing a query. For more information on the
instantiation process, see SAP Note 1764658

SAP HANA Modeling Guide


6 PUBLIC Modeling Calculation Views in SAP Web IDE for SAP HANA
It is also recommended to see the SAP Note 2618790 for some best practices to model views that are
semantically correct and to avoid unexpected results.

Related Information

Creating a Graphical Calculation View [page 8]

SAP HANA Modeling Guide


Modeling Calculation Views in SAP Web IDE for SAP HANA PUBLIC 7
3 Creating a Graphical Calculation View

A calculation view allows users to define more advanced slices on the data available in the SAP HANA
database.

Calculation views are mainly used for analyzing operational data marts or running multidimensional reports on
revenue, profitability, and more. Calculation views consume various combinations of content data (that is, non-
metadata) to model a business use case. You can classify content data as:

● Attributes: Descriptive data - such as customer ID, city, and country.


● Measures: Quantifiable data - such as revenue, quantity sold, and counters.

Calculation views simulate entities (such as customer, product, sales, and more) and their relationships. Data
visualization and analysis applications such as SAP BusinessObjects Explorer and Microsoft Office based
reporting tools consume these calculation views and help decision makers in their decision process.

You can create calculation views with layers of calculation logic, which include measures sourced from multiple
source tables, or advanced SQL logic, and much more. The data sources in a calculation view can include any
combination of tables and calculation views. You can create joins, unions, projections, and aggregations on
data sources.

Calculation views can include measures and be used for multidimensional reporting, or can contain no
measures and used for list-type reporting. Calculation views can do the following:

● Support both OLAP and OLTP models.


● Support complex expressions (for example, IF, Case, Counter).
● Support analytic privileges (for example, restricting a user for a certain cost center).
● Support SAP ERP specific features (for example, client handling, language, currency conversion).
● Combine facts from multiple tables.
● Support additional data processing operations (for example, Union, explicit aggregation).
● Leverage both Column and Row tables.

Related Information

Attributes and Measures [page 9]


Create Graphical Calculation Views [page 10]
Preview Calculation View Output [page 94]

SAP HANA Modeling Guide


8 PUBLIC Creating a Graphical Calculation View
3.1 Attributes and Measures

Attributes and measures form content data that you use for data modeling. The attributes represent the
descriptive data, such as region and product. The measures represent quantifiable data such as revenue and
quantity sold.

Attributes

Attributes are the nonmeasurable analytical elements.

Attributes Description Example

Simple Attributes Individual nonmeasurable analytical ele­ For example, PRODUCT_ID and PRODUCT_NAME
ments that are derived from the data are attributes of product data source.
sources.

Calculated Attributes Derived from one or more existing attrib­ For example, deriving the full name of a customer
utes or constants. (first name and last name), assigning a constant
value to an attribute that can be used for arithmetic
calculations.

Measures

Measures are measurable analytical elements that are derived from calculation views.

Measures Description Example

Simple Measures A simple measure is a measurable analyti­ For example, PROFIT.


cal element that is derived from the data
sources.

Calculated Measures Calculated measures are defined based on For example, you can use calculated measures to
a combination of data from other data calculate the net profit from revenue and opera­
sources, arithmetic operators, constants, tional cost.
and functions.

Counters Counters add a new measure to the calcu­ For example, to count how many times product
lation view definition to count the distinct appears and use this value for reporting purposes.
occurrences of an attribute.

Related Information

Working With Attributes and Measures [page 97]

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 9
3.2 Create Graphical Calculation Views

Create graphical calculation views using a graphical editor to depict a complex business scenario. You can also
create graphical calculation views to include layers of calculation logic.

Context

Graphical calculation views can bring together normalized data that are dispersed. You can combine multiple
transaction tables while creating a graphical calculation view.

Procedure

1. Start SAP Web IDE in a Web browser.


2. If you want to create a new project for the calculation view, do the following:

a. In the SAP Web IDE, choose File New Project from Template .
b. Choose the project template type.

Currently, there is only one type of project template available, namely: Multi-Target Application Project.
Select Multi-Target Application Project and choose Next.
c. Type a name for the new MTA project (for example, myApp and choose Next to confirm).
d. Specify details of the new MTA project and choose Next to confirm.
e. Create the new MTA project; choose Finish.
3. Select the SAP HANA Database Module in which you want to create the calculation view.

 Tip

If you do not already have a database module, right-click the root folder of your new MTA project and, in
the context menu, choose New SAP HANA Database Module .

4. Browse to the src folder, right-click it and choose New Calculation View .
5. Enter the details for the new calculation view.
a. In the Name field, enter the name of the calculation view.
b. In the Data Category dropdown list, select a value.
6. Choose Create.
The tool launches a new graphical calculation view editor with a semantics node and a default view node.
The default view node can be an aggregation or a projection view node and depends on the data category
that you have selected while creating the calculation view. If you are creating a calculation view with star
join, then the default view node is a star join view node.

SAP HANA Modeling Guide


10 PUBLIC Creating a Graphical Calculation View
 Note

You can switch between the default view nodes. For example, from a default aggregation view node to a
project view node or a star join view node. Right-click the default view node and select the required
menu option.

7. Continue modeling the graphical calculation view by dragging and dropping the necessary view nodes from
the tool palette to the view editor. You can switch between any of the inner aggregation or projection view
nodes by right-clicking the view node and selecting the required menu option. The tool retains the same
name after the switch operation.
8. Add data sources.

If you want to add data sources to the view node,

a. Select a view node.

b. In the editor toolbar, choose (Expand Details Panel).

c. Choose (Add Data Source).


d. In the Find Data Sources dialog box, select the type of the data source.
e. Enter the name of the data source and select it from the list.
You can add one or more data sources depending on the selected view node.
f. Choose Finish.

 Note

Supported data sources in view nodes in the current version.

The Find Data Sources dialog box displays multiple object types in the search result. But,
depending on the selected view node, you can only add activated (built) catalog tables, calculation
views, CDS entities, CDS views, virtual tables, and table functions as data sources in the view
nodes.

You can also model calculation views using data sources from any tenant database available in the
same SAP HANA instance.

9. (Optional) Add data sources from external services (HDI or non HDI containers).
You can use synonyms to access objects from user-defined schemas (non HDI) or from HDI containers.
The tool automatically creates (or modifies the existing) .hdbsynonym, .hdbgrants,
and .hdbsynonymtemplate (for objects in HDI), files that are necessary to consume the synonym.

 Note

You can access data sources from external services only if you have created the necessary user-
provided service and configured it in the mta.yaml file. For more information see, Add an External
Service in the mta.yaml File [page 176].

a. Select a view node.

b. Choose (Add Data Source).


The tool opens the Find Data Sources dialog box.
c. In the External Services dropdown list, select the required external service.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 11
d. Enter the name of the data source you want to access from the external service and select it from the
search list.
You can add one or more data sources depending on the selected view node.
e. Choose Create Synonym.
f. (Optional) Modify the synonym name.
g. Define the object owner role and the application user role.

Object Type Steps

Objects in HDI Con­ If the selected object is from a HDI container,


tainers
1. In the Object Owner Role, enter the name of the object owner role.

2. In the Application User Role, enter the name of the application user role.

For more information on roles for HDI containers, see the topic, Roles (.hdbrole) in the SAP
HANA Developer Guide (for XS Advanced).

If the object for which you are creating the synonym is in a HDI container, select Synonym
for HDI Container. This selection helps the tool identify that you are creating synonym for an
object in the HDI container.

Objects in non HDI If the selected object is from a HDI container,


containers
1. In the Object Owner Role, enter the name of the object owner role.

2. In the Application User Role, enter the name of the application user role.

For more information on roles for non HDI containers, see the topic, Enable Access to Ob­
jects in a Remote Classic Schema in the SAP HANA Developer Guide (for XS Advanced).

 Note
If the object for which you are creating the synonym is in a non HDI container, ensure
that you have not selected the Synonym for HDI Container checkbox.

h. Choose Finish.
The tool creates the synonym along with the .hdbsynonym, .hdbgrants,
and .hdbsynonymtemplate (for objects in HDI) files in the same SAP HANA Database Module.

10. Define output columns.


a. Select a view node.
b. On the Mapping tab, select the column you want to add to the output.
c. In the context menu, choose Add To Output.
d. If you want to add all columns in a data source to the output, then from the context menu of the data
source, select Add To Output.

 Note

Using keep flag property. The Keep Flag property on attribute columns influence the result set. Use
Keep Flag property, for example, if you want to aggregate the measures by performing an SQL
GROUP BY operation on them, even when they are not included in the query.

1. Select the view node.

SAP HANA Modeling Guide


12 PUBLIC Creating a Graphical Calculation View
2. On the Mapping tab, select an output column.
3. In the Properties section, set the value of Keep Flag property to True.

11. Define attributes and measures.


To successfully activate a calculation view with data category as CUBE, you must specify at least one
column as a measure.
a. Select the Semantics view node.
b. On the Columns tab, select a column value.
c. In the Type dropdown list, select Measure or Attribute.
If the data category is set to Cube, an additional aggregation column is available to specify the
aggregation type for measures.
12. (Optional) Copy a calculation view.
You can copy a calculation view and paste it using a different name within the same or different SAP HANA
Database module. The tool automatically adjusts the calculation view ID in the view properties.
a. In the Workspace view, right-click the required calculation view.
b. Choose Copy.
c. Right-click at the target folder and choose Edit Paste .
d. Provide a new name.
e. Choose OK.
13. (Optional) View modeler objects in the outline pane.
Use the outline pane in SAP Web IDE to obtain a quick overview of the modeler objects (view nodes and
columns) in the calculation view.

a. In the menu bar, choose View Outline .


The tool displays all modeler objects in the calculation view. You can also select an object in the outline
pane, and navigate to the editor to identify where the object is used in the calculation view.

b. In the right menu bar, choose (Outline) to show or hide the outline pane.
14. Choose Save on the menu bar to save your calculation view.
15. Build an SAP HANA Database Module.
The build process uses the design-time database artifacts to generate the corresponding runtime objects
in the database catalog.
a. From the module context menu, choose Build.

Next Steps

After creating a graphical calculation view, you can modify the output to your needs. The following table shows
how you can modify the calculation view.

Working With View Nodes


Requirement Task to Perform

Query data from two data sources and combine records from both the data sources, Create Joins
based on a join condition, or to obtain language-specific data.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 13
Requirement Task to Perform

Combine the results of two or more data sources. Create Unions

Partition the data for a set of partition columns, and perform an order by SQL opera­ Create Rank Nodes
tion on the partitioned data.

Execute any of the available graph operations on the graph workspace. Create Graph Nodes

Perform intersect set operations on two data sources. Use Intersect Set Operation

Perform minus set operations on two data sources. Use Minus Set Operation

Model calculation views with SAP HANA hierarchy functions. Use Hierarchy Functions

Anonymize calculation view output. Anonymize Data Using Calculation


Views

Model table functions in calculation views with both tabular input parameters and Model Table Functions as View No­
scalar input parameters.
des

Filter the output of view nodes. Filter Output of View Nodes.

Use a form-based editor to create virtual tables. Create Virtual Tables

Working With Columns


Requirement Task to perform

Count the number of distinct values for a set of attribute columns. Create Counters

Create new output columns and calculate their values at runtime using an expres­ Create Calculated Columns
sion.

Assign semantic types to provide more meaning, and to attach information about the Assign Semantics
type of attributes and measures in calculation views.

Parameterize calculation views and execute them based on the values users provide Create Input Parameters
at query runtime.

Filter the results based on the values that users provide to attributes at runtime. Assign Variables

Create level hierarchies to organize data in reporting tools. Create Level Hierarchies

Create parent-child hierarchies to organize data in reporting tools. Create Parent-Child Hierarchies

Associate measures with currency codes and perform currency conversions. Associate Measures with Currency

Associate measures with unit of measures and perform unit conversions. Associate Measures with Unit of
Measure

Define data masking for column values when modeling a calculation view. Mask Column Values in Client Tools

Define default values for columns (both attributes and measures) when no value is Handle Null Values in Columns
provided during a SQL INSERT operation.

Group related measures and related attributes together in a folder. Group Related Measures and Attrib­
utes

SAP HANA Modeling Guide


14 PUBLIC Creating a Graphical Calculation View
Working With Calculation View Properties
Requirement Task to perform

Filter the view data either using a fixed client value or using a session client set for Filter Data for Specific Clients
the user.

Invalidate or remove data from the cache after specific time intervals. Invalidate Cached Content

Prevent use of a calculation view. Deprecate Calculation Views

Execute time travel queries on calculation views. Enable Calculation Views for Time
Travel Queries

Related Information

Working With View Nodes [page 27]


Preview Calculation View Output [page 94]
Working With Attributes and Measures [page 97]
Working With Calculation View Properties [page 153]
Additional Functionality for Calculation Views [page 176]
Defining Data Access Privileges [page 161]
Create Graphical Calculation Views with Star Joins [page 15]
Create Graphical Calculation Views with Time Dimension [page 17]
Example: Using Keep Flag [page 92]
Create Virtual Tables [page 24]

3.2.1 Create Graphical Calculation Views with Star Joins

Star joins connect a central data entity to multiple entities that are logically related. You can create a graphical
calculation view with star joins that join multiple dimensions to a single fact table.

Context

Star joins in calculation views help join a fact table with dimensional data. The fact table contains data that
represent business facts such as, price, discount values, number of units sold, and more. Dimension tables
represent a collection of information. The information can include entities such as, geography, time intervals,
contact names and more.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 15
Procedure

1. Start SAP Web IDE in a Web browser.


2. If you want to create a new project for the calculation view, do the following:

a. In the SAP Web IDE, choose File New Project from Template .
b. Choose the project template type.

Currently, there is only one type of project template available, namely: Multi-Target Application Project.
Select Multi-Target Application Project and choose Next.
c. Type a name for the new MTA project (for example, myApp and choose Next to confirm).
d. Specify details of the new MTA project and choose Next to confirm.
e. Create the new MTA project; choose Finish.
3. Select the SAP HANA Database Module in which you want to create the calculation view.

 Tip

If you do not already have a database module, right-click the root folder of your new MTA project and, in
the context menu, choose New SAP HANA Database Module .

4. Browse to the src folder, right-click it and choose New Calculation View .
5. Enter the details for the new calculation view.
a. In the Name field, enter the name of the calculation view.
b. In the Data Category dropdown list, select CUBE.

 Note

You can create a star join with data category as CUBE or SQL Access Only only.

c. Select the With Star Join checkbox.


6. Choose Create.
The tool opens a new graphical calculation view editor with a semantics node and a star join node.
7. Add data sources.
a. Select the Star Join node.

b. Choose (Add Data Source).


c. In the Find Data Sources dialog box, enter the name of the calculation view with descriptive data.

 Note

When adding calculation views as a data source in a star join node, you can use only calculation
views with these data category types: dimension or blank.

d. Choose Finish.
8. Add inputs to the star join node.

Continue modeling the graphical calculation view with a cube structure, which includes attributes and
measures. The input to the star join node must provide the central fact table.
9. Maintain star join properties.
a. Select the Star Join node.

SAP HANA Modeling Guide


16 PUBLIC Creating a Graphical Calculation View
b. In the editor toolbar, choose (Expand Details Panel).

c. Choose (Create Join)


d. Create a join by selecting the required column from the left table, and dragging the cursor to the
required column in the right table.
e. (Optional) If you want to swap the left tables and right tables, then in the Join Creation dialog box,

choose (Swap Table).


f. In the General Properties section, define necessary join properties.
10. Choose Save in the menu bar to save your calculation view.
11. Build an SAP HANA Database Module.
The build process uses the design-time database artifacts to generate the corresponding actual objects in
the database catalog.
a. From the module context menu, choose Build.

3.2.2 Create Graphical Calculation Views with Time


Dimension

Add time dimension to a calculation view by using the standard time-related tables as data sources in the
calculation view.

Prerequisites

You have the time-related tables with time data or have synonyms to the time-related tables
(M_TIME_DIMENSION_YEAR, M_TIME_DIMENSION_MONTH, M_TIME_DIMENSION_WEEK,
M_TIME_DIMENSION, M_FISCAL_CALENDAR) in the same SAP HANA Database Module in which you are
creating the calculation view.

 Note

You can also generate time data in the standard time-related tables that are available in the _SYS_BI
schema and use them as data sources in the calculation view.

Procedure

1. Start SAP Web IDE in a Web browser.


2. If you want to create a new project for the calculation view, do the following:

a. In the SAP Web IDE, choose File New Project from Template .
b. Choose the project template type.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 17
Currently, there is only one type of project template available, namely: Multi-Target Application Project.
Select Multi-Target Application Project and choose Next.
c. Type a name for the new MTA project (for example, myApp and choose Next to confirm).
d. Specify details of the new MTA project and choose Next to confirm.
e. Create the new MTA project; choose Finish.
3. Select the SAP HANA Database Module in which you want to create the graphical calculation view.

 Tip

If you do not already have a database module, right-click the root folder of your new MTA project and, in
the context menu, choose New SAP HANA Database Module .

4. Browse to the src folder, right-click it and choose New Calculation View .
5. Enter the details for the new calculation view.
a. In the Name field, enter the name of the calculation view.
b. In the Data Category dropdown list, select Dimension.
c. In the Type dropdown list, select TIME.
d. Select the Auto Create checkbox if you want the tool to automatically include the time-related tables as
data sources in the calculation view, and also to define filters and hierarchies in the view based on the
selected calendar type and the granularity.
e. In the Calendar dropdown list, select the required calendar type.
f. If you have selected the Gregorian calendar type, in Granularity dropdown list, select the required
granularity.
g. Based on the Calendar type and the Granularity type (for Gregorian), in the Table field, use the Find
Data Sources dialog box to search and select the time-related tables or the synonyms to the time-
related tables.
6. Choose Create.
The tool opens a new calculation view editor. If you have not selected Auto Create, manually include the
required time-related tables as data sources and define filters, hierarchies based on your requirement.

 Note

For the Fiscal calendar type, Auto Create only includes the M_FISCAL_CALENDAR table as data source
in the calculation view. It does not automatically define any filters or hierarchies in the view.

7. Choose Save in the menu bar to save your calculation view.


8. Build an SAP HANA Database Module.
The build process uses the design-time database artifacts to generate the corresponding actual objects in
the database catalog.
a. From the module context menu, choose Build.

Related Information

Create Time-Related Tables and Generate Time Data [page 19]


Generate Time Data in the _SYS_BI Schema [page 20]
Supported Calendar Types For Generating Time Data [page 22]

SAP HANA Modeling Guide


18 PUBLIC Creating a Graphical Calculation View
Supported Time Range for Generating Time Data [page 22]

3.2.2.1 Create Time-Related Tables and Generate Time


Data

The tool allows users to create time-related tables in an SAP HANA Database Module and generate time data
into these tables.

Context

You can add a time-dimension to a calculation view by using the time-related tables from an SAP HANA
Database Module as data sources in the view. To generate time data, the tool supports Gregorian and Fiscal
calendar types.

Procedure

1. Start SAP Web IDE in a Web browser.

2. In the Workspace view, right-click the SAP HANA Database Module and choose Modeling Actions
Maintain Time Tables .
3. In the Generate Time Data dialog box, select the required calendar type.
4. Calendar type - Gregorian.
If you have selected Gregorian as the calendar type, then
a. Select all the required granularity levels for which you want to create the time-related tables.

 Note

For the granularity level Week, specify the first day of the week.

b. If you want to generate time data into the tables after creating them, select Generate Data After
Creation and specify the From year and To year for which you want to generate time data.
c. Choose Generate.
The tool automatically creates the time-related tables for the selected granularity. Browse to the
time_tables folder under the src folder in the SAP HANA Database Module to access the time-related
tables.
5. Calendar type - Fiscal.
If you have selected Fiscal as the calendar type, then
a. Select Create or Update Fiscal Table.
b. If you want to generate time data into the tables after creating them, select Generate Data After
Creation and specify the From year and To year for which you want to generate time data.
c. In the Variant field, use the value help to search and select the table that contains variant data.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 19
 Note

SAP tables T009 and T009B are typically used to store any variant data.

d. In the Variant dropdown list, select the required variant.


The variant specifies the number of periods along with the start and end dates.
e. Choose Generate.
The tool automatically creates the time-related tables for the selected granularity. Browse to the
time_tables folder under the src folder in the SAP HANA Database Module to access the time-related
tables.

Related Information

Generate Time Data in the _SYS_BI Schema [page 20]


Supported Calendar Types For Generating Time Data [page 22]
Supported Time Range for Generating Time Data [page 22]

3.2.2.2 Generate Time Data in the _SYS_BI Schema

Generate time data into the standard time-related tables that are available in the _SYS_BI schema. You can
use these standard time-related tables as data sources in the calculation view to add a time dimension to the
view.

Prerequisites

You have INSERT privileges on the time-related tables. You can use the SAP HANA database explorer to add a
SYSTEM database user.

Context

Use the SAP HANA database explorer to generate time-related data in the standard time-related tables. You
can specify the calendar type and the granularity to generate time data. The tool supports Gregorian and Fiscal
calendar types..

Procedure

1. Start the SAP Web IDE in a Web browser.

SAP HANA Modeling Guide


20 PUBLIC Creating a Graphical Calculation View
2. In the left sidebar, choose (Database Explorer).
3. Select the required HDI service for which the user has INSERT privileges on the time-related tables.
4. In the context menu, choose Generate Time Data.
5. In the Calendar Type dropdown list, select the required calendar type.
6. In the From Year and To Year text fields, enter the start year and end year for which you want to generate
time data into the standard time-related tables.
7. If you have selected Gregorian as the calendar type, in the Granularity dropdown list, select the required
granularity.

 Note

For the granularity level Week, specify the first day of the week.

8. If you have selected Fiscal as the calendar type,


a. In the Schema text field, enter the name of the variant schema that contains tables having variant data.

 Note

SAP tables T009 and T009B are typically used to store the variant data.

b. In the Variant text field, enter the required variant.

The variant specifies the number of periods along with the start and end dates.
9. Choose OK.

 Note

For the Gregorian calendar type, the tool generates the time data in the M_TIME_DIMENSION_YEAR,
M_TIME_DIMENSION_MONTH, M_TIME_DIMENSION_WEEK, M_TIME_DIMENSION tables. For the
Fiscal calendar type, the tool generates the time data in the M_FISCAL_CALENDAR table. These tables
are available in the _SYS_BI schema.

Related Information

Create Graphical Calculation Views with Time Dimension [page 17]


Supported Calendar Types For Generating Time Data [page 22]
Supported Time Range for Generating Time Data [page 22]

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 21
3.2.2.3 Supported Calendar Types For Generating Time
Data

In SAP Web IDE the following calendar types are supported for generating time data.

Calendar Type Description

Gregorian Use the Gregorian calendar type, if your financial year is same as the calendar
year, for example, January to December.

Fiscal Use the Fiscal calendar type, if your financial year is not same as the calendar
year, for example, March to April.

3.2.2.4 Supported Time Range for Generating Time Data

For the Gregorian calendar type, based on the granularity you choose, the tool provides restrictions on the time
range for which you can generate time data.

For each granularity level, the following table displays the time range that the tool supports for generating time
data.

Granularity Range

Seconds <= 5 years

Minutes <= 15 years

Hour <= 30 years

Day <= 50 years

Week <= 50 years

Month <= 50 years

Year <= 50 years

 Note

The following restrictions are applicable for generating time dimension data:

● Minimum start year: 1900


● Maximum end year: 2200
● Maximum years generated: 50

SAP HANA Modeling Guide


22 PUBLIC Creating a Graphical Calculation View
3.2.2.5 MDX Commands for Time-related Tables

The tables M_TIME_DIMENSION, M_TIME_DIMENSION_WEEK and M_TIME_DIMENSION_MONTH stores time-


related information, which are used in time dimensions.

The filling of these tables can be triggered by the following SQL commands:

MDX UPDATE TIME DIMENSION DAY 2010 2020; --> generates data in
"_SYS_BI"."M_TIME_DIMENSION"
MDX UPDATE TIME DIMENSION WEEK 2010 2020; --> generates data in
"_SYS_BI"."M_TIME_DIMENSION_WEEK"
MDX UPDATE TIME DIMENSION MONTH 2010 2020; --> generates data in
"_SYS_BI"."M_TIME_DIMENSION_MONTH"
MDX UPDATE TIME DIMENSION YEAR 2010 2020; --> generates data in
"_SYS_BI"."M_TIME_DIMENSION_YEAR"

MDX Commands for Fiscal Generation

MDX UPDATE FISCAL CALENDAR [<schema for T009 tables>] <variant> <startYear>
<endYear> [<mandt>] [WITHLEADINGZEROES] [TARGET_SCHEMA <schema of the time
table>] [TARGET_TABLE <name of time table>]

<> - value of parameter; [] - optional; | - or; all else - constants

If TARGET_SCHEMA is not specified, then _SYS_BI is used. Similarly, if TARGET_TABLE is not specified, then
M_FISCAL_CALENDAR is used.

MDX Commands for Time Generation

MDX UPDATE TIME DIMENSION SECOND|MINUTE|HOUR|DAY|WEEK|MONTH|YEAR <startYear>


<endYear> [FIRST_DAY_OF_WEEK MONDAY|TUESDAY|WEDNESDAY|THURSDAY|FRIDAY|SATURDAY|
SUNDAY] [TARGET_SCHEMA <schema of the time table>] [TARGET_TABLE <name of time
table>]

<> - value of parameter; [] - optional; | - or; all else - constants.

If TARGET_SCHEMA is not specified, then _SYS_BI is used. Similarly, if TARGET_TABLE is not specified, then
depending on the granularity, the following tables are used:

● M_TIME_DIMENSION_MONTH
● M_TIME_DIMENSION_WEEK
● M_TIME_DIMENSION_YEAR
● M_TIME_DIMENSION

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 23
3.2.3 Create Virtual Tables

In SAP Web IDE, you can use a wizard to create virtual tables. Virtual tables allow you to access objects in other
databases without having to replicate to SAP HANA.

Prerequisites

You must already have created a remote source.

Context

The SAP Web IDE supports creating virtual tables with a code editor or a wizard. Creating virtual tables with the
wizard helps, for example, to create virtual tables when you are not aware of the syntax to create them with the
code editor. After creating the virtual tables, you can use them as data source.

Procedure

1. Start SAP Web IDE in a Web browser.


2. If you want to create a new project for the virtual table, do the following:

a. In SAP Web IDE, choose File New Project from Template .


b. Choose the project template type.
c. Type a name for the new project (for example, myApp) and choose Next to confirm.
d. Specify details of the new project and choose Next to confirm.
e. Create the new project; choose Finish.
3. Select the SAP HANA Database Module in which you want to create the virtual table.

 Tip

To create a database module, right-click the root folder of your new project and, in the context menu,
choose New SAP HANA Database Module .

4. Browse to the src folder, right-click it and choose New Virtual Table .
5. In the Create Virtual Object wizard, select a remote source and click Next.
6. Use the filter parameters to search for one or more remote objects you want to create a virtual table from
and click Next.
7. Enter a name for the virtual object and click Finish.

Use the naming format namespace::virtual_table_name.


8. Choose Save in the menu bar to save your calculation view.
9. Build an SAP HANA Database Module.

SAP HANA Modeling Guide


24 PUBLIC Creating a Graphical Calculation View
The build process uses the design-time database artifacts to generate the corresponding actual objects in
the database catalog.
a. From the module context menu, choose Build.

3.2.4 Supported View Nodes for Modeling Calculation Views

The SAP Web IDE graphical calculation view editor offers various view nodes to model calculation views and
obtain the desired output.

The following table lists shows the various view nodes.

View Node Description Icon Example

For retrieving customer details and location based on


Use the join view node to query data the Postal_Code column in the CUSTOMER and
from two data sources, based on a GEOGRAPHY tables. The CUSTOMER table has columns
Join specified condition. Customer_ID, Customer_Name, and
Postal_Code. The GEOGRAPHY table has columns
Join view nodes can have two or
Customer_ID, Postal_Code, Region, and
more inputs.
Country.

Use the non equi join view node to


Non Equi create join conditions with various
Join comparisions or unequal operators
(<, >=, !=, ...) on several columns.

Use the union view node to combine


the result set of two or more data For retrieving the names of all employees of a store,
Union sources. which has different branches, with each branch main­
taining its own employee records table.
Union view nodes can have two or
more inputs.

Use the minus view node in calcula­ Perform minus set operations on SALES_2017 and
Minus tion views to perform minus set oper­ SALES_2016 to identify those products that were sold
ations on two data sources. in 2017, but not in the year 2016.

Use the intersect view node in calcu­ Perform intersect set operations on SALES_2016 and
Intersect lation views to perform intersect set SALES_2017 to identify the products sold during 2016
operations on two data sources. and 2017.

Use the graph view node to execute Execute graph actions such as the shortest path or the
any of the available graph operations strongest connection between components in the graph
Graph or actions on the graph workspace. workspace. The graph workspace includes the definition

You can use this view node as the leaf of the vertex table and edge table that are required to

node in the calculation view only. execute the action.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 25
View Node Description Icon Example

Use the projection view node to filter


or obtain a subset of required col­
umns of a data source (tables, views, For selecting the employee name and employee depart­
Projection
table functions, and more). ment from a table consisting of many other columns.

Projection view nodes can have only


one input.

Use the aggregation view node to


summarize data for a group of row
values, by calculating values in a col­ For retrieving total sales of a product in a month. The
Aggregation supported aggregation types are SUM, MIN, VAR,
umn.
STDDEV, MAX, COUNT, AVG.
Aggregation view nodes can have
only one input.

Use the rank view node to partition


Retrieving the top five products, based on sales, from a
the data for a set of partition col­
Rank TRANSACTION table with columns PRODUCT and
umns, and to perform an order by op­
SALES.
eration on the partitioned data.

Use the table function view nodes to For modeling a table function TFProfit
Table Func­ model table functions with both tab­ (Sales(ID, NetSales, Category) with tabu­
tion ular input parameters and scalar in­ lar input parameters (ID, NetSales) and scalar in­
put parameters. put parameter (Category).

Use the hierarchy function view no­


Hierarchy des to use SAP HANA hierarchy func­
Function tions in the calculation view defini-
tion.

Use the anonymization view nodes to

Anonymiza­ anonymize calculation view output.

tion You can use this view node as the leaf


node in the calculation view only.

 Note

You can add data sources, unions, joins, projections, or aggregations as inputs to view nodes.

Related Information

Working With View Nodes [page 27]

SAP HANA Modeling Guide


26 PUBLIC Creating a Graphical Calculation View
3.2.5 Working With View Nodes

View nodes are the building blocks of calculation views. They help you build complex and flexible analytic
models, and each view node type possess specialized capabilities that can trigger advanced features in the
database.

This section describes the different view nodes that you can use within graphical calculation views, along with
examples of how you can use them to model calculation views.

Related Information

Create Joins [page 27]


Create Temporal Joins [page 32]
Create Unions [page 45]
Create Rank Nodes [page 59]
Create Graph Nodes [page 62]
Filter Output of View Nodes [page 88]
Use Intersect Set Operation [page 70]
Use Minus Set Operation [page 72]
Use Hierarchy Functions [page 74]
Anonymize Data Using Calculation Views [page 81]
Model Table Functions as View Nodes [page 86]

3.2.5.1 Create Joins

Use join view nodes in calculation views to query data from two or more data sources.

Context

The join view nodes help combine columns from two data sources using records that are common to both the
data sources. By default, a join is an equi join because the condition to create such joins are based on the
equality of two values.

Procedure

1. Open the required calculation view in the view editor.


2. From the tool palette of the editor, drag a join view node to the editor.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 27
3. Add data sources.
a. Select the join view node.

b. Choose (Add Data Source).


c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.
d. Choose Finish.

In the editor canvas, you can view only limited number of columns. However, in the Mapping tab, you can
view all columns from the data sources.
4. Define output columns.

a. In the editor toolbar, choose (Expand Details Panel).


b. On the Mapping tab, select the columns you want to add to the output of the join view node.
c. In the context menu, choose Add To Output.

 Note

If you want to add all columns of a data source to the output, in the context menu of the data
source, choose Add To Output.

5. Create a join between two data sources.


a. Choose the Join Definition tab.

b. Choose (Create Join)


c. Create a join by selecting the required column from the left table, and dragging the cursor to the
required column in the right table.
d. (Optional) If you want to swap the left tables and right tables, then in the Join Creation dialog box,

choose (Swap Table).


If you have more than two data sources in the join view node, you can create multiple join definitions
within a single join view node (multi join). For each join definition, in the Left Table dropdown list and in
the Right Table dropdown list, you can select the required left table and right table for the join
definition.
6. Define join properties.
a. In the Join Creation dialog box, expand the General Properties section.
b. Define necessary values for the join properties.

7. (Optional) Use the proposed join cardinality.


The tool analyses the data of tables participating in the join and proposes an optimal cardinality that you
can use while defining the join properties.

a. In the General Properties section, choose (Propose Cardinality) next to the Cardinality dropdown
list.
The tool can propose an optimal cardinality. Choose Yes to use the proposed cardinality.

 Note

Choosing a valid cardinality for your data sources is necessary to avoid incorrect results from the
engine, and to attain better performance. Provide any cardinality value only if you are aware of the
optimal cardinality for your join.

SAP HANA Modeling Guide


28 PUBLIC Creating a Graphical Calculation View
8. Choose OK.
9. (Optional) Define multi join properties.
The tool supports creating joins between several data sources within a single join view node. If you are
creating multiple join definitions (multi join), specify the central table and the order in which the tool must
execute the join condition.
a. In the view editor, select a data source in the join view node and expand the Properties pane.
b. In the Multi Join Order dropdown list, select the required order.
By default, the join order is Outside In. It implies that the join condition is executed from the outside to
the inside with the central table as the reference (ending with the central table). If you set the join order
as Inside Out, the tool executes the join condition from the inside to the outside (starting from the
central table).
c. In the Central Table dropdown list, select the required data source that you want to use a central table
in the join execution.
10. (Optional) Define calculated columns.
a. Choose the Calculated Columns tab.
b. Choose + (Add).
c. Select and expand the new calculated column.
d. Define the calculated column.
11. (Optional) Define input parameters or variables.
a. Choose the Parameters tab.

b. Choose (Add).
c. Select Input Parameter or Variable menu option.
d. Select and expand the new input parameter or variable.
e. Define the input parameter or variable.
12. (Optional) Filter output of join view node.
Apply filters on output columns of the join view node to filter the output results.
a. Choose the Filter Expression tab.
b. In the Language dropdown list, select the required language.
c. In the expression editor, enter the expression that defines the required filter conditions.
Use the elements, functions, and operators in the Filter Expression tab to build your expression.
For example,

(revenue >= 100 AND region = India) OR (revenue >=50 AND region = Germany)

13. Add result as inputs to other view nodes.


a. In the view editor, select the join view node.

b. Choose .
c. Drag the cursor to the view node for which you want to provide the input.

Related Information

Create Temporal Joins [page 32]

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 29
Create Spatial Joins [page 35]
Text Joins [page 39]
Dynamic Joins [page 40]
Optimize Join Execution [page 42]
Join Properties [page 43]
Supported Join Types [page 44]
Create Calculated Columns [page 99]
Create Input Parameters [page 112]

3.2.5.1.1 Create Non Equi Joins

Use the non equi join view nodes to create join conditions with various comparisions or unequal operators (<,
>=, !=, ...) on several columns.

Context

A non equi join uses comparison operators like !=, >, <, >= and <= to query data from two data sources. Like a
normal join, it allows you to specify the cardinality and a join type (Inner, Left Outer, Right Outer) to query data
from two data sources. If multiple pairs of left and right columns are participating in join definition, each pair
can have different operator.

 Restriction

You can add only two data sources in non equi jon view nodes and cannot create non equi joins between
fact table and shared dimensions.

Procedure

1. Open the required calculation view in the view editor.


2. From the tool palette of the editor, drag a non equi join view node to the editor.
3. Add data sources.
a. Select the non equi join view node.

b. Choose (Add Data Source).


c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.
d. Choose Finish.
4. (Optional) Create constants.
You can create constant values in any of the data source and use them in the join definition. Creating
constant helps, for example, when you want to define a join condition by comparing a column value with a
constant value.

SAP HANA Modeling Guide


30 PUBLIC Creating a Graphical Calculation View
a. Choose the Join Definition tab.
b. Select the data source in which you want to create the constant value.
c. In the menu bar, choose +.
d. Provide the required constant value.
e. Choose OK.
5. Define output columns.

a. In the editor toolbar, choose (Expand Details Panel).


b. On the Mapping tab, select the columns you want to add to the output of the non equi join view node.
c. In the context menu, choose Add To Output.

 Note

If you want to add all columns of a data source to the output, in the context menu of the data
source, choose Add To Output.

6. Create a join.
a. Choose the Join Definition tab.

b. Choose (Create Join).


c. Create a join by selecting the required column from the left table, and dragging the cursor to the
required column in the right table.
d. (Optional) If you want to swap the left tables and right tables, then in the Join Creation dialog box,

choose (Swap Table).


7. Define non equi join properties.
a. In the Join Creation dialog box, expand the Non Equi Join Properties section.
b. Define necessary values for the join properties.

 Restriction

For non equi joins, you cannot create temporal joins, text joins, referential joins, dynamic joins.

c. In the Operator dropdown list, select the required operator.


If multiple pairs of left and right columns are participating in join definition, each pair can have different
operator.

 Caution

In non equi join view nodes, using the EQ operator in the join condition may impact the
performance of the join execution. To define join conditions with EQ operator, we recommend you
to use the normal join view node (equi join).

8. (Optional) Using the proposed join cardinality.


The tool analyses the data of tables participating in the join and proposes an optimal cardinality that you
can use while defining the join properties.

a. In the Non Equi Join Properties section, choose (Propose Cardinality) next to the Cardinality
dropdown list.
The tool can propose an optimal cardinality. Choose Yes to use the proposed cardinality.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 31
 Note

Choosing a valid cardinality for your data sources is necessary to avoid incorrect results from the
engine, and to attain better performance. Provide any cardinality value only if you are aware of the
optimal cardinality for your join.

9. Choose OK.
10. (Optional) Define calculated columns.
a. Choose the Calculated Columns tab.
b. Choose + (Add).
c. Select and expand the new calculated column.
d. Define the calculated column.
11. (Optional) Define input parameters or variables.
a. Choose the Parameters tab.

b. Choose (Add).
c. Select Input Parameter or Variable menu option.
d. Select and expand the new input parameter or variable.
e. Define the input parameter or variable.
12. Add result as inputs to other view nodes.
a. In the view editor, select the non equi join view node.

b. Choose .
c. Drag the cursor to the view node for which you want to provide the input.

 Note

You cannot create calculated columns or any filter expressions in non equi join view nodes.

3.2.5.1.2 Create Temporal Joins

Temporal joins let you create join between the transaction data (fact table) and the master data. These joins
help query data within a temporal interval.

Context

In the join conditons for temporal columns, apart from the join columns, you can specify the temporal column
from fact table and temporal interval from dimension table.

SAP HANA Modeling Guide


32 PUBLIC Creating a Graphical Calculation View
Procedure

1. Open the calculation view in the view editor.


2. Select the Star Join node.

You can create temporal joins in the star join node only. The star join node must contain a calculation view
with a Dimension data category type as the data source, and the input to the star join node must provide
the central fact table.
3. Add data sources.
a. Select the join view node.

b. Choose (Add Data Source).


c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.
d. Choose Finish.
4. Define output columns.

a. In the editor toolbar, choose (Expand Details Panel).


b. On the Mapping tab, select the columns you want to add to the output of the join view node.
c. In the context menu, choose Add To Output.

 Note

If you want to add all columns of a data source to the output, in the context menu of the data
source, choose Add To Output.

5. Create a join.

Create a join by dragging a column from the shared calculation view (master table) to a column in the other
data source (fact table).
a. Choose the Join Definition tab.

b. Choose (Create Join)


c. Create a join by selecting the required column from the left table, and dragging the cursor to the
required column in the right table.
d. (Optional) If you want to swap the left tables and right tables, then in the Join Creation dialog box,

choose (Swap Table).


6. Define the temporal column and the temporal conditions.

In the Temporal Properties section, provide values to create the temporal join.
a. In the Temporal Column dropdown list, select a time column in the calculation view.
b. In the Temporal Condition dropdown list, select a temporal condition.
c. In the From Column and To Column dropdown lists, specify the start and end time values from the
calculation view to fetch the records.
7. Choose OK.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 33
Related Information

Temporal Joins [page 34]


Temporal Conditions [page 34]
Example: Temporal Joins [page 35]

3.2.5.1.2.1 Temporal Joins

A temporal join lets you set time intervals for which you want to fetch records. It indicates the time interval
mapping between the master data and the transaction data.

Temporal joins are based on the date and time field from the fact table, and the time interval (to and from
fields) from the master data view. The date field from the fact table is called temporal column.

If the temporal column values in the fact table are within the valid time interval values from the master data
view that means the tables are joined. A time interval is assigned to each record in the results set. These
records are valid for the duration of the interval to which they are assigned.

The supported data types for Temporal Column, From Column, and To Column are timestamp, date, time, and
integers only.

3.2.5.1.2.2 Temporal Conditions

Temporal condition values, which you define in temporal joins, help determine whether to include or exclude
the boundary values.

The boundary values of the time interval is defined by the FROM and TO date fields of the master data view,
while executing the join condition. The following table lists the temporal conditions.

Temporal Condition Meaning

Include To Exclude From This temporal condition includes the value of the To Column field and excludes the value
of the From Column field while executing the join.

Exclude To Include From This temporal condition excludes the value of the To Column field and includes the value
of the From Column field while executing the join.

Exclude Both This temporal condition excludes the value from both the To Column field and the From
Column field while executing the join.

Include Both This temporal condition includes the value from both the To Column field and From
Column field while executing the join.

SAP HANA Modeling Guide


34 PUBLIC Creating a Graphical Calculation View
3.2.5.1.2.3 Example: Temporal Joins

Create temporal joins to join the master data with the transaction data (fact table), based on a time column
value from the transaction data and the time validity columns from the master data.

Consider a dimension calculation view named PRODUCT (master data) with attributes PRODUCT_ID,
VALID_FROM_DATE, and VALID_TO_DATE and a calculation view of type cube, SALES (transactional data) with
attributes PRODUCT_ID, DATE, and REVENUE.

Now, you can create a temporal join between the master data view and transaction data using the attribute
PRODUCT_ID to analyze sales of the product for a particular period.

3.2.5.1.3 Create Spatial Joins

Create spatial joins to query data from data sources that have spatial data.

Context

You use the join view node in a calculation view to create spatial joins, and create them by joining two database
tables on columns of spatial data types.

Procedure

1. Open the required calculation view in the view editor.


2. From the tool palette of the editor, drag a join view node to the editor.
3. Add data sources.
a. Select the join view node.

b. Choose (Add Data Source).


c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.
d. Choose Finish.
4. Define output columns.

a. In the editor toolbar, choose (Expand Details Panel).


b. On the Mapping tab, select the columns you want to add to the output of the join view node.
c. In the context menu, choose Add To Output.

 Note

If you want to add all columns of a data source to the output, in the context menu of the data
source, choose Add To Output.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 35
5. Create a join.

Create a join by dragging a column from the shared calculation view (master table) to a column in the other
data source (fact table).

a. Choose the Join Definition tab.

b. Choose (Create Join)


c. Create a join by selecting the required column from the left table, and dragging the cursor to the
required column in the right table.
d. (Optional) If you want to swap the left tables and right tables, then in the Join Creation dialog box,

choose (Swap Table).


6. Define spatial join properties.
In the Spatial Join section, define the necessary spatial join properties.
a. In the Predicates dropdown list, select a predicate value.
Spatial predicates are conditions that return Boolean results. They serve as join conditions for spatial
joins.

 Note

If you select Relate as the predicate value, in the Intersection Matrix text field enter the required
values. Similarly, if you select Within Distance as the predicate value, in the Distance field, select a
value. You can provide the distance as a fixed value or use an input parameter to provide the
distance value at runtime.

b. If you want to execute the spatial join only if the predicate condition evaluates to true, in the Execute
Join If dropdown list, select Predicate Evaluates to True.
7. Choose OK.

Related Information

Supported Spatial Predicates [page 36]


Supported Spatial Data Types [page 38]

3.2.5.1.3.1 Supported Spatial Predicates

The following spatial predicates are supported.

Method Type Description

ST_Contains ST_Geometry Tests if a geometry value spatially con­


tains another geometry value.

SAP HANA Modeling Guide


36 PUBLIC Creating a Graphical Calculation View
Method Type Description

ST_CoveredBy ST_Geometry Tests if a geometry value is spatially


covered by another geometry value.

ST_Covers ST_Geometry Tests if a geometry value spatially cov­


ers another geometry value.

ST_Crosses ST_Geometry Tests if a geometry value crosses an­


other geometry value.

ST_Disjoint ST_Geometry Test if a geometry value is spatially dis­


joint from another value.

ST_Equals ST_Geometry Tests if a ST_Geometry value is spatially


equal to another ST_Geometry value.

ST_Intersects ST_Geometry Test if a geometry value spatially inter­


sects another value.

ST_Overlaps ST_Geometry Tests if a geometry value overlaps an­


other geometry value.

ST_Relate ST_Geometry Tests if a geometry value is spatially re­


lated to another geometry value as
specified by the intersection matrix.
The ST_Relate method uses a 9-
character string from the Dimensionally
Extended 9 Intersection Model
(DE-9IM) to describe the pair-wise rela­
tionship between two spatial data
items. For example, the ST_Relate
method determines if an intersection
occurs between the geometries, and
the geometry of the resulting intersec­
tion, if it exists.

ST_Touches ST_Geometry Tests if a geometry value spatially


touches another geometry value.

ST_Within ST_Geometry Tests if a geometry value is spatially


contained within another geometry
value.

ST_WithinDistance ST_Geometry Test if two geometries are within a


specified distance of each other.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 37
3.2.5.1.3.2 Supported Spatial Data Types

The following spatial data types are supported in data models and query language for storing and accessing
geospatial data.

Data Type Description

Geometries The term geometry means the overarching type for objects such as points, linestrings, and
polygons. The geometry type is the supertype for all supported spatial data types.

Points A point defines a single location in space. A point geometry does not have length or area. A
point always has an X and Y coordinate.

ST_Dimension returns 0 for non-empty points.

In GIS data, points are typically used to represent locations such as addresses, or geo­
graphic features such as a mountain.

Multipoints A multipoint is a collection of individual points.

In GIS data, multipoints are typically used to represent a set of locations.

Linestrings A linestring is geometry with a length, but without any area. ST_Dimension returns 1 for
non-empty linestrings. Linestrings can be characterized by whether they are simple or not
simple, closed or not closed. Simple means a linestring that does not cross itself. Closed
means a linestring that starts and ends at the same point. For example, a ring is an exam­
ple of simple, closed linestring.

In GIS data, linestrings are typically used to represent rivers, roads, or delivery routes.

Multilinestring A multilinestring is a collection of linestrings.

In GIS data, multilinestrings are frequently used to represent geographic features like riv­
ers or a highway network.

Polygons A polygon defines a region of space. A polygon constructed from one exterior bounding
ring defines the outside of the region and zero or more interior rings, which define holes in
the region. A polygon has an associated area but no length.

ST_Dimension returns 2 for non-empty polygons.

In GIS data, polygons are typically used to represent territories (countries, towns, states,
and more), lakes, and large geographic features such as parks.

Multipolygons A multipolygon is a collection of zero or more polygons.

In GIS data, multipolygons are frequently used to represent territories made up of multiple
regions (for example a state with islands), or geographic features such as a system of
lakes.

SAP HANA Modeling Guide


38 PUBLIC Creating a Graphical Calculation View
3.2.5.1.4 Text Joins
A text join helps obtain language-specific data. It retrieves columns from a text table based on the session
language of the user.

The text tables contain description for a column value in different languages. For example, consider a PRODUCT
table that contains PRODCUT_ID and a text table PRODUCT_TEXT that contains the columns PRODUCT_ID,
DESCRIPTION, and LANGUAGE.

PRODUCT

PRODUCT_ID SALES

1 1000

2 2000

3 4000

PRODUCT_TEXT

PRODUCT_ID LANGUAGE DESC

1 E Description in English.

1 D Description in German.

2 E Description in English.

3 E Description in English.

Create a text join to join the two tables and retrieve language-specific data using the language column
LANGUAGE. For example, if your session language is E and if you have added all columns to the output of the join
view node, the output of the text join is:

PRODUCT_ID LANGUAGE DESC SALES

1 E Description in English. 1000

2 E Description in English. 2000

3 E Description in English. 4000

 Note

For text joins, always add the text table as the right table.

When you execute a query, the engine evaluates the language setting of your connection. The texts are
selected based on the language setting.

You can set the language when you add a container in the SAP HANA database explorer. If you want to see the
English language being selected, then when adding a container, in the Advanced Options, specify LOCALE=en.

You can further specify the language like en_US. For more information, see 2364550 .

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 39
3.2.5.1.5 Dynamic Joins

After creating a join between two data sources, you can define the join property as dynamic. Dynamic joins
helps improve the join execution process by reducing the number of records processed by the join view node at
runtime.

Dynamic joins are special type of joins. In this join type, two or more fields from two data sources are joined
using a join condition that changes dynamically based on the fields requested by the client. For example –
Table1 and Table2 are joined on Field1 and Field2. But, if only one, Field1 or Field2 is requested by a client, the
tables (Table1 and Table2) are joined based only on the requested field (Field1 or Field2).

 Note

You can set the Dynamic Join property only if the two data sources are joined on multiple columns.

Dynamic join behavior is different from the classical join behavior. In the classical join, the join condition is
static. This means that, the join condition does not change irrespective of the client query. The difference in
behavior can result in different query result sets. Use dynamic joins with caution.

Prerequisite

At least one of the fields involved in the join condition is part of the client query. If you define a join as dynamic,
the engine dynamically defines the join fields based on the fields requested by the client query. But, if the field
is not part of the client query, it results in query runtime error.

Static Join Versus Dynamic Joins

● In static joins, the join condition isn't changed, irrespective of the client query.
● In a dynamic join, if the client query to the join doesn't request a join column, a query runtime error occurs.
This behavior of dynamic join is different from the static joins.
● Dynamic join enforces aggregation before executing the join, but for static joins the aggregation happens
after the join. This means that, for dynamic joins, if a join column is not requested by the client query, its
value is first aggregated, and later the join condition is executed based on columns requested in the client
query.

Related Information

Example: Dynamic Joins [page 41]

SAP HANA Modeling Guide


40 PUBLIC Creating a Graphical Calculation View
3.2.5.1.5.1 Example: Dynamic Joins

Consider that you want to evaluate the sales of a product and also calculate the sales share of each product
using the following data sources.

SALES

REGION COUNTRY SALES

APJ IND 10

APJ IND 10

APJ CHN 20

APJ CHN 50

EUR DE 50

EUR DE 100

EUR UK 20

EUR UK 30

PRODUCT

REGION COUNTRY PRODUCT

APJ IND PROD1

APJ IND PROD2

APJ CHN PROD1

APJ CHN PROD2

EUR DE PROD1

EUR DE PROD2

EUR UK PROD1

EUR UK PROD2

So you use a calculation view to join the above two data sources via two different aggregation view nodes as
inputs to the join view node. The aggregation view node with the data source SALES does not has the PRODUCT
column but contains total sales for a given region or country.

Now assume that the two aggregation view nodes join dynamically on the columns, REGION and COUNTRY.
The outputs of the join view node are columns REGION, PRODUCT, SALES and the calculated columns,
TOT_SALES, and SALES_SHARE.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 41
When you execute a client query on the calculation view to calculate the sales share of a product at a region
level, the output from the dynamic join and static join is different:

Dynamic Join

REGION PRODUCT SALES TOT_SALES SALES_SHARE

APJ PROD1 30 90 .33

APJ PROD2 60 90 .66

EUR PROD1 70 200 .35

EUR PROD2 130 200 .65

Static Join

REGION PRODUCT SALES TOT_SALES SALES_SHARE

APJ PROD1 30 90 .78

APJ PROD2 60 90 1.21

EUR PROD1 70 200 .73

EUR PROD2 130 200 1.26

The dynamic join calculates the sales share at the region level by aggregating the sales values before joining the
data sources. The static join, on the other hand, first calculates the sales share at the region level and the
country level (because the join condition contains both region and country), and then aggregates the resulting
sales share after the join is executed.

3.2.5.1.6 Optimize Join Execution

While executing the join, by default, the query retrieves join columns from the database even if you don't
specify it in the query. The query automatically includes the join columns into the SQL GROUP BY clause
without you selecting them in the query.

You can avoid this default behavior by using the join property Optimizing Join Columns. When this property for
a join is set to True, only the columns specified in the query are retrieved from the database.

 Note

Optimizing join columns is supported only for left outer joins with cardinality 1:1 or N:1, text joins with
cardinality 1:1 or N:1, right outer joins with cardinality 1:1 or 1:N, and referential joins.

If the filters are defined on join columns for which you have enabled Optimize Join Columns, the join optimizer
cannot remove attributes of static filters. In this case, you can optimize the join column by introducing a
dummy projection view node between the join and the input node with static filters.

SAP HANA Modeling Guide


42 PUBLIC Creating a Graphical Calculation View
 Note

Optimize join columns are not supported for non equi joins.

Prerequisites

● The join field is not requested in the query


● Only fields from one join partner are requested in the query.
● The join is an outer join, referential, or text join.
● The cardinality to the join partner from which no fields are requested is set to 1.

Scenario: Using the Optimizing Join Columns Property

Consider a scenario in which a query requests only fields from one join partner, the cardinality to the other
partner (of which no fields are requested) is set to 1, and the join is not an inner join. In such scenarios, the join
execution does not influence the result set. You can use the optimize join columns property to prune the fields
that are not requested in the query.

In general, for scenarios that have multiple join partners on different join fields, if the query requests fields from
only a small subset of join partners, you can use the optimize join columns property to omit various join fields
from the aggregation. This flag helps to explicitly state to the join optimizer to not include the join fields in the
aggregation. Omitting the join fields help reduce the number of records processed by the join optimizer.

This optimization therefore results in a better performance and lower memory consumption. The extent of
optimization depends on the fields that the query request at runtime, and on which fields you have defined the
join.

 Remember

Using a wrong cardinality impacts the result set.

3.2.5.1.7 Join Properties

After creating a join, define its properties to obtain a desired output when you execute the join.

The tool lets you to define the following join properties.

Join Properties Description

Join Type The value of this property specifies the join type used for creating a join. For more information,
see Supported Join Types [page 44].

Cardinality The value of this property specifies the cardinality used for creating a join.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 43
Join Properties Description

By default, the cardinality of the join is empty. If you are uncertain about the right cardinality for
the join tables, we recommend you to not specify any cardinality. The system determines the
cardinality when executing the join.

Language Column The value of this property specifies the language column that the tool must use for executing text
joins. For more information, see Text Joins [page 39].

Dynamic Join The value of this property determines whether the tool must dynamically define the columns of
the join condition based on the client query. For more information, see Dynamic Joins [page 40].

Optimize Join The value of this property determines whether the tool must retrieve the columns that are not
Columns specified in the query from the database. For more information, see Optimize Join Execution
[page 42].

3.2.5.1.8 Supported Join Types


When creating a join between two data sources (tables or column views) in a join view node, you specify the join
type. The table shows the supported join types in a join view node.

Join Type Description

Inner Returns all rows when there is at least one match in both the data sources.

Left Outer Returns all rows from the left data source, and the matched rows from the right data
source.

Right Outer Returns all rows from the right data source, and the matched rows from the left data
source.

Text Join This join type is used to obtain language-specific data from the text tables using a lan­
guage column.

Full Outer Displays results from both left and right outer joins and returns all (matched or un­
matched) rows from the tables on both sides of the join clause.

Referential This join type is similar to inner join type, but assumes that referential integrity is main­
tained for the join tables.

Optimizing Referential Joins

You can optimize the performance of referential joins by additionally specifying the join direction. The join
direction provides more information to the optimizer on the direction of referential integrity, which helps prune
tables participating in the join condition.

The following are prerequisites to optimize referential joins.

● The join type is Referential.


● The query on the calculation view does not request any fields from the to-be-pruned table.
● The join cardinality is set to “..1” or "1.." based on the join direction for the to-be-pruned table.

The tool supports the following as the join directions for referential joins.

SAP HANA Modeling Guide


44 PUBLIC Creating a Graphical Calculation View
Direction Description

Left It is the default join direction and implies that the referential integrity is provided by
the left table.

Right Referential integrity is provided by the right table.

Both The optimizer evaluates both the tables in the join condition.

3.2.5.2 Create Unions

Use union view nodes in calculation views to combine the results of two or more data sources.

Context

A union view node combines multiple data sources. These data sources can have multiple columns. You can
manage the output column of a union view node by:

● Mapping the source columns to the output columns or


● Create a target output column with constant values and map the source columns with the constant values.

For source columns, which do not have mappings to any of the output columns, create a target output column
and map it to the unmapped source columns.

Procedure

1. Open the required calculation view in the view editor.


2. From the tool palette of the editor, drag and drop a union view node to the editor.
3. Add data sources.
a. Select the union view node.

b. Choose
c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list. (Add
Data Source).
d. Choose Finish.
4. Define output columns.

a. In the editor toolbar, choose (Expand Details Panel).


b. On the Mapping (Add pane, select the columns you want to add to the output of the union view node.
c. In the context menu, choose Add To Output.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 45
 Note

If you want to add all columns from the data source to the output, in the context menu of the data
source, choose Add To Output.

5. (Optional) Create constant output columns.


Create new output columns and assign it with constant values.
a. Choose the Mappings tab.
b. In the Output Columns section, choose + (Create Constant).
c. In the Create Target and Manage Mapping dialog box, provide a name for the new constant output
column.
d. Provide the required data type, length, and scale values.
e. In the Source Column dropdown list, select the required column from the data source with which you
want to map the constant output column.
f. In the Constant Value text field, provide the required constant value.
g. Select is Null checkbox, if you want to assign a null value to the constant output column.

 Note

If you do not provide any constant value, then the tool, by default, considers the constant output
column value as null.

h. Choose OK.
6. (Optional) Define calculated columns.
a. Choose the Calculated Columns tab.
b. Choose + (Add).
c. Select and expand the new calculated column.
d. Define the calculated column.
7. (Optional) Define input parameters or variables.
a. Choose the Parameters tab.

b. Choose (Add).
c. Select Input Parameter or Variable menu option.
d. Select and expand the new input parameter or variable.
e. Define the input parameter or variable.
8. Add result as inputs to other view nodes.
a. In the view editor, select the union view node.

b. Choose .
c. Drag the cursor to the view node for which you want to provide the input.

Related Information

Example: Constant Columns [page 57]


Empty Union Behavior [page 58]
Prune Data in Union Nodes [page 48]

SAP HANA Modeling Guide


46 PUBLIC Creating a Graphical Calculation View
Create Calculated Columns [page 99]
Assign Variables [page 107]
Create Input Parameters [page 112]

3.2.5.2.1 Data Types of Output Columns in Union View


Node

In Union view nodes, columns of different data sources can be mapped to the same output column. The tool
determines the data type of the output columns based on certain rules.

The data type of the input column is determined by the data type of the column in the source. Therefore, it
typically corresponds to the data type of the column in a source table. The data type of the output column is
determined by the below rules.

As a general rule, avoid implicit castings of input columns. Instead, map input columns of the same data type
with the same output column. Nevertheless, if columns of some specific data types are mapped, implicit
casting happens. Below is a list of the data types for which implicit casting happens.

In the following, we refer to data types NVARCHAR, VARCHAR and SHORTTEXT with the term “string_type”
and to data types TINY, SMALL, INTEGER with the term “integer_type”.

In the list below “ x <-> y “ means that implicit casting happen between data type x and data type y.

Implicit casts happen:

● within integer_type: TINY <-> SMALL <-> INTEGER


● within string_types: NVARCHAR <-> VARCHAR <-> SHORTTEXT
● DATE <-> TIMESTAMP <-> string_type
● VARBINARY <-> string_type

 Note

Do not rely on implicit casting between other data types. In future releases we will open up implicit castings
between additional data types and list this in the documentation and SAP Note 2823865.

Currently, NCLOB, BLOB, LOB are only implicitly casted if they are not used as the first data source of the
UNION node ( “x -> y” means that implicit casting only happens from data type x to data type y but not the
other way around):

● string_type -> NCLOB


● string_type -> BLOB
● string_type -> LOB
● string_type -> TEXT

For example, UNION of string_type and NCLOB would work while the reverse order, UNION of NCLOB and
string_type, would fail.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 47
3.2.5.2.2 Prune Data in Union Nodes

Pruning data in union view nodes help optimize the query execution on the union view node. To prune data, you
need a pruning configuration table that specifies the filter conditions to limit the result set.

Context

You can manually create pruning configuration tables (.hdbcds tables) or use the form-based table editor that
the tool provides to create them. After creating a pruning configuration table, reference it in the target
calculation view properties.

 Remember

If the queries executed on the union view node unfolds and does not perform any aggregation, then the tool
does not prune data. In such cases, switch off the unfolding behavior with the hint,
NO_CALC_VIEW_UNFOLDING.

Unfolding is the normal query execution behavior in which the query execution is passed to the SQL engine or
the optimizer after the calculation engine instantiates the query. This unfolding behavior is not possible for
complex calculation views.

Procedure

1. Open the required calculation view in which you want to define the data pruning for its union view nodes.
2. Edit view properties.
a. Select the Semantics node.

b. In the editor toolbar, choose (Expand Details Panel).


c. Choose the View Properties tab.
d. Choose Advanced.
3. If you have already created a pruning configuration table and if you want to use the same for the selected
calculation view, then in the Pruning Configuration Table field, use the search to find and add the required
table.

 Note

You can use only tables or views as pruning configuration tables.

4. If you want to create a new pruning configuration table, choose +.


a. In the Table Name text field, enter a name for the pruning configuration table.
b. Choose + to add a filter condition that limits the result set of a union view node.
You can add more than one filter condition in a single pruning configuration table. If you are creating
multiple filter conditions using the same column, then the filter conditions are combined using the
logical OR operator. But, if you are using different columns to provide the filter conditions, then the
filter conditions are combined using the logical AND operator.

SAP HANA Modeling Guide


48 PUBLIC Creating a Graphical Calculation View
c. In the Input field, use the value help to select a data source in the union view node.
d. In the Column field, use the value help to select a column from the data source.
e. In the Operators dropdown list, select the required operator to define the filter condition.
f. Use the Low and High text fields based on the selected operator to define the filter condition.
5. Choose Create and Build.
The tool creates the pruning configuration table and all other files (.hdbcds, .hdbtabledata, and .csv) that
are necessary to prune the data. These files are created in the same SAP HANA Database Module in which
you have created the calculation view.

6. (Optional) Choose (Edit Pruning Configuration) to edit an existing pruning configuration table used for
the selected calculation view.

Related Information

Union Node Pruning [page 49]


Pruning Configuration Table [page 51]
Example with a Pruning Configuration Table [page 51]
Example with a Constant Mapping [page 54]
Example Tables [page 56]

3.2.5.2.2.1 Union Node Pruning

Union node pruning allows the data sources in union nodes to be pruned. It is based on defined criteria that at
runtime exclude specific data sources from the processing. This helps reduce resource consumption and
benefits performance.

To prune data sources, you need either a pruning configuration table or a constant mapping. If you opt for the
configuration table approach, you use a table to specify data slices contained in the individual data sources.
This information is matched to the query filter when the query is run, and as a result, only the required data
sources are processed. With constant mapping, you define a constant with specific values for each data source
and select the appropriate value in your query.

For example, you are creating a sales report for a product across the years using a calculation view. The
calculation view consists of two data sources, one with the current sales data (for YEAR >= 2018) and the other

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 49
with the archived sales data (YEAR <= 2017). Both are provided as input to a union node in the calculation view,
as shown below:

In your scenario, you want to query the calculation view to get the results of CURRENT_SALES only. You
therefore want the query to be executed on the CURRENT_SALES data source only, and the operation on the
archived data source to be excluded (that is, pruned). To do so, you have the following options:

● You provide a pruning definition in a pruning configuration table.


● You create a constant that maps the data sources to specific constant values.

 Note

In general, constant mapping improves performance more but is less flexible than using a pruning
configuration table.

 Note

If a union node is consumed by a rank node, query filters will, by default, not be pushed down to it when the
query is executed. This applies to filter expressions and variables used in a WHERE clause. However, to be
able to apply pruning, the union node needs the filters. In these cases, therefore, the combination of rank
node and union node with pruning only makes sense if the Allow Filter Push Down option has been activated
for the rank node.

Related Information

Pruning Configuration Table [page 51]

SAP HANA Modeling Guide


50 PUBLIC Creating a Graphical Calculation View
Example with a Pruning Configuration Table [page 51]
Example with a Constant Mapping [page 54]
Example Tables [page 56]
Push Down Filters in Rank Nodes
SAP Note 2752070

3.2.5.2.2.1.1 Pruning Configuration Table

A pruning definition in a pruning configuration table has a specific format.

The format of a pruning configuration table is as follows:

Column Name Description

CALC_SCENARIO Fully qualified name of the calculation view to which union node pruning
is to be applied. For example, p1.p2::CV_PRUNING, where p1.p2 is the
namespace and CV_PRUNING is the name of the calculation view.

INPUT Name of the data source in the union node of the calculation view.

COLUMN Target column name

OPTION Operator (=, <, >, <=, >=, BETWEEN)

LOW_VALUE Filter condition

HIGH_VALUE Filter condition

To assign a pruning configuration table to a calculation view, select the Semantics node and choose View
Properties Advanced . Note that if you have not already created a pruning configuration table, you can both
create and build it from here.

3.2.5.2.2.1.2 Example with a Pruning Configuration Table

In this example, you use a pruning configuration table to specify the filter conditions for pruning the union
node. A matching filter is then applied in the WHERE clause of the query so that only one of the data sources is
processed.

Context

The calculation view is based on the example shown earlier. The Union node is used to combine the two data
sources Current_Sales and Old_Sales. In the procedure below, you query the calculation view to get the current
sales results only.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 51
Procedure

1. Create a pruning definition in a pruning configuration table. For example:

Table: UNION_PRUNING

CALC_SCENARIO INPUT COLUMN OPTION LOW_VALUE HIGH_VALUE

1 p1.p2::CV_PRUNING OldSales YEAR <= 2017 NULL

2 p1.p2::CV_PRUNING CurrentSales YEAR >= 2018 NULL

 Note

You can also create the table within step 3.

2. In the calculation view, select the Semantics node and choose View Properties Advanced .
3. In the Pruning Configuration Table field, use the search to find and add the pruning configuration table
created above, or choose + to create the table. For example:

The calculation view now contains the pruning configuration table with the two data sources CurrentSales
and OldSales.
4. Build the calculation view.
5. Execute a query on the calculation view with a filter condition that is the same as the condition defined in
the pruning configuration table. For example:

SELECT
"SALESORDER",
"PRODUCT",
"YEAR",
SUM("SALES") AS "SALES"
FROM "JOINCARDINALITYEXAMPLE_HDI_DB_1"."p1.p2::CV_PRUNING"
WHERE "YEAR" >= '2018'
GROUP BY "SALESORDER", "PRODUCT", "YEAR";

6. From the Run dropdown menu, choose Analyze SQL.

SAP HANA Modeling Guide


52 PUBLIC Creating a Graphical Calculation View
7. On the Operators tab, filter by the Column Table operator.

As can be seen, only the Current_Sales table is accessed. For example:

This confirms that the union node could be pruned because the filter condition matches the one in the
pruning configuration table.
8. Remove the pruning configuration table from the view properties of the calculation view and build it again.
9. Enter the same query as above and choose Analyze SQL from the Run dropdown menu.
10. On the Operators tab, filter by the Column Table operator.

As can be seen, the query is now invoking both the archived sales data and current sales data, although
only the current sales data is required. For example:

The presence of the Old_Sales table indicates that the union node was not pruned.

Results

As demonstrated therefore, union node pruning in calculation views allows the execution flow to be determined
dynamically based on the query. This allows resource consumption to be reduced and performance improved.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 53
3.2.5.2.2.1.3 Example with a Constant Mapping

In this example, you use a constant to define the criteria for pruning the union node and then apply it in the
WHERE clause of the query.

Context

The calculation view is based on the example shown earlier. The Union node is used to combine the two data
sources Current_Sales and Old_Sales. In the procedure below, you use the debug feature to visualize the
pruning.

Procedure

1. Create a calculation view with a Union node as follows:

2. Create a constant to differentiate between the two different data sources:


a. On the Mapping tab of the Union node, choose + (Create Constant) in the Output Columns toolbar.
b. Enter the details required to differentiate between the two data sources. For example:

SAP HANA Modeling Guide


54 PUBLIC Creating a Graphical Calculation View
3. Save and build the calculation view.
4. To start debugging, select the Semantics node and then choose the Debug button.
5. On the Debug Query tab, add the following WHERE clause to the default debug query:

WHERE "SALESYEAR" = 'CURRENT'

For example:

SELECT "SALESORDER",
"PRODUCT",
"YEAR",
SUM("SALES") AS "SALES"
FROM "JOINCARDINALITYEXAMPLE_HDI_DB_1"."p1.p2::UNION_PRUNING"
WHERE "SALESYEAR" = 'CURRENT'
GROUP BY "SALESORDER", "PRODUCT", "YEAR", "SALESYEAR";

6. Click Execute to run the query.

The Old_Sales data source is now grayed out, indicating that is not being processed. For example:

The reason why it has been excluded is that the SALESYEAR filter does not match the constant value OLD
that you defined for it.
7. Rerun the debug query but replace CURRENT with OLD.
For example:

SELECT "SALESORDER",
"PRODUCT",
"YEAR",
SUM("SALES") AS "SALES"

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 55
FROM "JOINCARDINALITYEXAMPLE_HDI_DB_1"."p1.p2::UNION_PRUNING"
WHERE "SALESYEAR" = 'OLD'
GROUP BY "SALESORDER", "PRODUCT", "YEAR", "SALESYEAR";

This time the Current_Sales data source is grayed out. For example:

Results

As shown above, when a constant is added to the union node of a calculation view, queries that apply a filter on
that constant will prune the applicable data sources in the Union node. This technique can be used to improve
the runtimes of complex models.

3.2.5.2.2.1.4 Example Tables

The following tables are used in the examples.

Current_Sales

SALESORDER PRODUCT YEAR SALES

006 PROD1 2018 450

006 PROD2 2018 330

006 PROD3 2018 510

007 PROD3 2018 1020

007 PROD1 2018 1350

007 PROD2 2018 990

008 PROD1 2018 450

008 PROD2 2018 330

009 PROD1 2018 900

009 PROD3 2018 1020

Old_Sales

SALESORDER PRODUCT YEAR SALES

001 PROD3 2016 510

001 PROD1 2016 450

SAP HANA Modeling Guide


56 PUBLIC Creating a Graphical Calculation View
Old_Sales

SALESORDER PRODUCT YEAR SALES

001 PROD2 2016 330

002 PROD1 2017 900

002 PROD3 2017 1020

002 PROD2 2017 660

003 PROD3 2017 510

004 PROD1 2017 450

004 PROD3 2017 510

005 PROD2 2017 330

3.2.5.2.3 Example: Constant Columns

Constant output columns help denote the underlying data from the source columns with constant values in the
output. You can also map the unmapped source columns to a constant output column based on the business
requirement.

For example, consider that you want to compare the planned sales of each quantity with its actual sales using
two data sources with similar structures, ACTUALSALES and PLANNEDSALES.

ACTUALSALES

SALES_QUANTITY PRODUCT_ID

5000 P1

3000 P2

PLANNEDSALES

SALES_QUANTITY PRODUCT_ID

4000 P1

4000 P2

When you use a union view node to combine the results of the two data sources, you cannot differentiate the
data from these data sources.

SALES_QUANTITY PRODUCT_ID

5000 P1

3000 P2

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 57
SALES_QUANTITY PRODUCT_ID

4000 P1

4000 P2

In such cases, create a constant output column PLANNED_OR_ACTUAL and assign the constant value ACTUAL
to ACTUALSALES and the constant value PLANNED to PLANNEDSALES.

SALES_QUANTITY PRODUCT_ID PLANNEDORACTUAL

5000 P1 ACTUAL

3000 P2 ACTUAL

4000 P1 PLANNED

4000 P2 PLANNED

Now, you can identify the data source and its underlying data.

3.2.5.2.4 Empty Union Behavior

The Empty Union Behavior property determines whether queries on union view nodes, ones with constant
output columns, return values when no other column from the data source is queried.

This property is useful, for example, for value help queries in applications. You can select either No Row or Row
with Constant as values for the Empty Union Behavior property. Select the data source in the mapping
definition and, in the Properties tab, define the values for this property based on your business requirement.

For understanding the Empty Union Behavior property and how its value determines the output data, consider
the following mapping definition in a union view node:

Constant values A and B are defined for Projection_1 and Projection_2 using the constant column, CONSTANT.

SAP HANA Modeling Guide


58 PUBLIC Creating a Graphical Calculation View
When you execute a query on a calculation view with this union view node, and if the column CUSTOMER_ID is
not queried, then the Empty Union Behavior property of Projection_2 determines whether the constant column,
CONSTANT returns the constant value, A for Projection_2 in the output:

● If the Empty Union Behavior property is set to No Row, then no data from Projection _2 appears in the
output data. Only data from Projection_1 appears in the output data.
● If the Empty Union Behavior property is set to Row with Constant, the output data includes one record from
Projection _2. In this one record, the constant value A appears for the CONSTANT column and values for all
other columns appears as null.

3.2.5.3 Create Rank Nodes

Use rank nodes in calculation views to perform a logical partition of the data for a set of partition columns, and
perform a ORDER BY SQL operation on the partitioned data.

Context

For example, consider a TRANSACTION table with two columns PRODUCT and SALES. If you want to retrieve the
top five products based on sales, use a rank node. The rank node first partitions the TRANSACTION table with
the PRODUCT as the partition column, and performs an order by operation on the partitioned table using the
SALES column to retrieve the top five products based on sales.

Procedure

1. Open the required calculation view in the view editor.


2. From the tool palette of the editor, drag the rank node to the editor.
3. Add data source.
a. Select the rank node.

b. Choose (Add Data Source).


c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.
d. Choose Finish.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 59
4. Define output columns.

a. In the editor toolbar, choose (Expand Details Panel).


b. On the Mapping tab, select the columns you want to add to the output of the rank node.
c. In the context menu, choose Add To Output.

 Note

If you want to add all columns from the data source to the output, in the context menu of the data
source, choose Add To Output.

5. Define the rank node.


a. Select the Definition tab.
b. In the Aggregation Function dropdown list, select a value.

Supported Aggregation Function for Rank Node


Function Description

Row This aggregation function sequentially numbers the


rows within a partition of a result set, with the first row
of each partition assigned as 1. The output of this func­
tion can be non-deterministic among tie values.

Rank This aggregation function returns duplicate values in


the ranking sequence when there are ties between val­
ues and the next rankings are skipped.

Dense Rank This aggregation function performs the same ranking


operation as the Rank function, except that rank num­
bering does not skip when ties are found.

Sum This aggregation function performs the ranking opera­


tion for records based on the cummilative sum speci­
fied as a target value for the sort column. The records
are ranked sequentially until the cummilative sum of the
the sort column records is equal to or lesser that the
target value specified.

 Note

The aggregation functions listed here are available with SPS 04 version onwards. If you have
created rank nodes with the earlier version, you can still open the calculation view in the edior and
work with the rank view nodes. But, in such cases you can only use the UI capabilities supported in
earlier versions for the rank view node. Therefore, if you are using an earlier version, then the
selected aggregation function only displays the functionality that was available in earlier versions.
To use the new features, switch the aggregation function.

For example on the behavior of these functions, see the Related Information section.

c. In the Result Set Direction dropdown list, select a value.

SAP HANA Modeling Guide


60 PUBLIC Creating a Graphical Calculation View
Result Set Direction
Value Description

TOP Retrieves top N records from the ordered set, where N is


the target value specified.

DOWN Retrieves bottom N records from the ordered set, where


N is the target value specified.

d. In the Result Set Type dropdown list, select a value.

Result set type


Type Description

Absolute If you want to specify the number of records to retrieve


from the ordered set as an absolute value.

Percentage If you want to specify the number of records to retrieve


from the ordered set as a percentage of the actual re­
sult set.

e. In the Target Value dropdown list, select a value.


The Target Value helps identify the number of records that the query must retreive to the output of the
rank node. If the target value is N, the query retrieves records from the ordered set with rank up to N.
You can specify the target value as a fixed value or use an input parameter to provide the value at
runtime.
f. In the Offset dropdown list, select a value.
The value helps offset or skip records with rank up to M from the ordered set to the output of the rank
node, where M is the offset value that you specify. You can provide the offset value as a fixed value or
use an input parameter to provide values at runtime.

6. Generate a rank column.


If you want to generate an additional output column in the rank node to store the rank values, select the
Generate Rank Column checkbox.
7. Partition the data.
The rank node enables you to perform logical partition of the ordered set using one or more partition
columns.
a. In the Logical Partition section, choose + (Add).
b. In the Column dropdown list, select a column that the tool must use to partition the data.
8. (Optional) Select the Dynamic Partition Elements checkbox.
Select to partition the data with only partition by columns that the query requests for processing the rank
node.

 Note

In the converse, without dynamic partition, the tool partitions the data with all partition by columns in
the Partition By section, even if these columns are not requested in the query.

9. Define ORDER BY columns and sort direction.


You can use one or more columns to ORDER BY and define the sort direction to order records in each
partition.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 61
a. In the Sort Column section, choose + to add one or mode columns as the ORDER BY columns.
b. In the Sort Direction dropdown list, select a sort direction.

Sort Direction Description

Descending Sort records in each partition in descending order.

Ascending Sort records in each partition in ascending order.

10. (Optional) Define input parameters or variables.


a. Choose the Parameters tab.

b. Choose (Add).
c. Select Input Parameter or Variable menu option.
d. Select and expand the new input parameter or variable.
e. Define the input parameter or variable.
11. Add result as inputs to other view nodes.
a. In the view editor, select the rank node.

b. Choose .
c. Drag the cursor to the view node for which you want to provide the input.

Related Information

Assign Variables [page 107]


Create Input Parameters [page 112]
DENSE_RANK Function (Window)
RANK Function (Window)
ROW_NUMBER Function (Window)

3.2.5.4 Create Graph Nodes

Using graph view nodes in calculation views enable you to use any of the supported SAP HANA Graph actions
on a graph workspace.

Prerequisites

You have at least one vertex table, one edge table, and one graph workspace, in the same SAP HANA Database
Module as the calculation view.

SAP HANA Modeling Guide


62 PUBLIC Creating a Graphical Calculation View
Context

Graphs are a powerful abstraction that can be used to model different kinds of networks and linked data
coming from many areas, such as logistics and transportation, utility networks, knowledge representation, text
processing, and more. SAP HANA Graph is an integral part of SAP HANA core functionality. It expands the SAP
HANA platform with native support for graph processing and allows you to execute typical graph operations on
the data stored in an SAP HANA system.

Procedure

1. Open the required calculation view in the view editor.


2. From the tool palette of the editor, drag a graph node to the editor.

 Note

You can add graph nodes in calculation views as leaf nodes only.

3. Add data sources.


a. Select the graph view node.

b. Choose (Add Data Source).


c. In the Find Data Sources you have at least one vertex table, one edge table, and one graph workspace,
in the same HDB dialog box, enter the name of a graph workspace and select it from the list.

 Note

You can add only a graph workspace as the data source in graph view nodes. An SAP HANA
Database Module can have multiple graph workspaces, vertex tables, or edge tables.

d. Choose Finish.
4. Select an action.

Select a supported action (a graph operation or algorithm) that you want to execute on the graph
workspace.

a. In the editor toolbar, choose (Expand Details Panel).

b. In the Action tab, choose (Change Algorithm).


c. Select the required action.
5. Define the parameters necessary to execute the action.
After selecting an action, define values for all parameters that are necessary to execute the action. You can
also create and use input parameters to provide values.

For pattern matching, you can use the graphical editor to visually compose the pattern. The pattern
comprises of vertices connected by edges. Use the + (Add Vertex) icon in the menu bar to add a vertex to
the editor and drag the cursor from one vertex to the other to create an edge. After composing your
pattern, define conditions on the vertex. In the Mapping tab, define the output columns.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 63
For pattern matching with cypher editor, write the required pattern matching query using the supported
subset of the Cypher query language on the given graph workspace. After writing the query, choose
Generate Column to create the output columns.
6. View output columns.

The output columns of a graph node vary depending on the action you select.
a. Select the Columns tab to view output columns of the graph node.
7. Create input parameters, if required.

a. Select the Parameters tab and create a new input parameter. You can create input parameters to
parameterize the execution of graph node and provide values at runtime to execute the graph node.

You can use this input parameter while defining the parameters necessary to execute a selected
action.
8. Add the results as input to other view nodes.

You can add the output of graph view nodes as inputs (to data source) to multiple view nodes at the same
time. If you are using Shortest Path action in your graph view node, you can optionally add the output edge

table from the graph view node as inputs to other view nodes. Select the graph node and choose (Edge
Output) to add the edge table as an input to a view node.

Related Information

SAP HANA Graph Model [page 64]


Graph Workspaces [page 65]
Supported Graph Actions in Calculation Views [page 65]

3.2.5.4.1 SAP HANA Graph Model

SAP HANA Graph is an integral part of SAP HANA core functionality. It expands the SAP HANA platform with
native support for graph processing and allows executing typical graph operations on the data stored in an SAP
HANA system.

The SAP HANA Graph model provides basic information for creating graphs to depict data relationships
visually. It allows typical graph operations to be run on the data stored in an SAP HANA system.

Graphs are powerful abstraction that can be used to model different kinds of networks and linked data coming
from many areas, such as logistics and transportation, utility networks, knowledge representation, text
processing, and more.

In SAP HANA, a graph is as a set of vertices and edges. Each edge connects two vertices; one vertex is denoted
as the source and the other as the target. Edges are always directed and there can be two or more edges
connecting the same two vertices. Vertices and edges can have an arbitrary number of attributes. Both vertices
and edge attributes consists of a name, which is associated with a data type and a value. Edge attributes
consist of the same information.

For more information about the SAP HANA Graph model, see SAP HANA Graph Reference Guide.

SAP HANA Modeling Guide


64 PUBLIC Creating a Graphical Calculation View
3.2.5.4.2 Graph Workspaces

A graph workspace is an object in the database that defines a graph that consists of tables and columns.

A graph workspace includes the following:

● Vertex table
● Edge table
● Key column in the vertex table
● Key column in the edge table
● Source in the edge table
● Target in the edge table

 Note

You can use CDS tables or SQL syntax to create vertex tables and edge tables. For more information on
how to create vertex tables and edge tables, see the SAP HANA Graph Reference guide.

Example Artifact Code


The following code shows a simple example of a graph workspace definition for XS advanced HDI:

 Code Syntax

/src/my_graph_workspace.hdbgraphworkspace

GRAPH WORKSPACE MY_GRAPH_WORKSPACE


EDGE TABLE THE_EDGE_TABLE
SOURCE COLUMN source TARGET COLUMN target KEY COLUMN edge_id
VERTEX TABLE THE_VERTEX_TABLE
KEY COLUMN vertex_id

Plug-in Configuration

In the configuration file for the HDI container (.hdiconfig), the plug-in configuration should look like the
following example:

 Code Syntax

.hdiconfig

"hdbgraphworkspace" : {
"plugin_name" : "com.sap.hana.di.graphworkspace",
"plugin_version": " "
}

3.2.5.4.3 Supported Graph Actions in Calculation Views

You can use the graph view node to execute any of the supported SAP HANA Graph actions on a graph
workspace.

The following table lists the supported graph actions that you can execute using the graph view node in a
calculation view.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 65
Action Description

Neighborhood Retrieves the neighboring vertices within the given radius (depth) from the given start
vertices.

Shortest Path (One-to-All) Provides the information for the shortest path from the starting vertex to all reachable
vertices.

Shorted Path (One-to-One) Returns the shortest path from the provided start vertex to the provided target vertex.

Strongly Connected Compo­ Calculates strongly connected components (SCC) in the given graph workspace.
nents

Pattern Matching Identifies all the subgraphs (within a graph) that match the given pattern.

Related Information

Neighborhood [page 66]


Shortest Path (One-to-All) [page 67]
Shortest Path (One-to-One) [page 68]
Strongly Connected Components [page 69]
Pattern Matching [page 69]

3.2.5.4.3.1 Neighborhood

The Neighborhood graph action retrieves the neighboring vertices within the given radius (depth) from the
start vertices.

This action lets you specify multiple start vertices, choose a traversal direction, set filters on vertices and
edges, and set minimum and maximum depth (radius) of the neighborhood.

This action has the following additional parameters:

Parameter Value

Start Vertices Set of start vertex keys.

Direction Traversal direction, can use one of the following values: any, incoming, and outgoing
(default: outgoing).

Minimum Depth Minimum depth (radius) of the neighborhood. 0 means that the start vertices are included
in the result.

Maximum Depth Maximum depth (radius) of the neighborhood.

SAP HANA Modeling Guide


66 PUBLIC Creating a Graphical Calculation View
Parameter Value

Vertex Filter Vertex filter expression analogous to SQL where-clause on the vertex table (default:
empty).

Edge Filter Edge filter expression analogous to SQL where-clause on the edge table (default: empty).

The output includes the following:

Output Column Description

Vertex Table Primary Key Contains the set of explored vertices with vertex table primary key.

Depth The depth level of the neighborhood.

3.2.5.4.3.2 Shortest Path (One-to-All)

This action provides information for the shortest path from the starting vertex to all reachable vertices.

Shortest Path action returns the shortest paths from the provided start vertex to all reachable vertices in the
graph also known as single-source shortest path (SSSP). The resulting shortest paths form a tree structure
with the start vertex at the root. All other vertices carry the shortest distance (smallest weight) information.
The non-negative edge weights are read from the column provided in the edge table.

This action has the following additional parameters:

Parameter Value

Start Vertex Start vertex key

Weight Column A column in the edge table that contains edge weights. If omitted, edge weights
are set to 1.

Direction Traversal direction, can use one of the following values: any, incoming, outgo­
ing.

The output includes the following:

Output Columns Description

Vertex table Contains vertex keys and corresponding smallest weights (shortest distances)

Edge table Edge table with shortest paths

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 67
3.2.5.4.3.3 Shortest Path (One-to-One)

This action returns the shortest path from the provided start vertex to the provided target vertex - also known
as single-source single-target shortest path (SSSTSP).

The resulting table contains all vertices with the distance to the start vertex that are part of the shortest path
between the start vertex and target vertex.

 Note

Theoretically, there is more than one shortest path between two vertices with the same distance. This
algorithm returns one of them.

The non-negative edge weights are read from the column provided in the edge table.

This action has the following additional parameters:

Parameter Value

Start Vertex Start vertex key

Target Vertex Target vertex key

Weight Column A column in the edge table that contains edge weights. If omitted, edge weights
are set to 1.

Direction Traversal direction, can use one of the following values: any, incoming, outgo­
ing.

The output includes the following:

Output Columns Description

Source Column Name in output table that contains the source of the traversed edge.

Default: source column name of graph workspace

Target Column Edge table with shortest paths

Ordering Name in output table that contains the target of the traversed edge.

Default: target column name of graph workspace

Vertex Table Primary Contains the set of explored vertices with vertex table primary key.
Key

Weight Output weight (shortest distance) column name (default: “WEIGHT”)

SAP HANA Modeling Guide


68 PUBLIC Creating a Graphical Calculation View
3.2.5.4.3.4 Strongly Connected Components
The Strongly Connected Components action calculates strongly connected components (SCC) in the given
graph workspace.

Strongly connected components partition the given graph workspace into largest subgraphs possible, where
every vertex is reachable from every other vertex. Knowing strongly connected components is helpful for cycle
detection, because, by definition, the cycles can only exist within strongly connected components and they
cannot cross strongly connected component boundaries.

The only output of this action is a table containing the vertex key column and a COMPONENT column containing
strongly connected component indexes. All vertices having the same component index belong to the same
strongly connected component.

The output includes the following:

Output Column Description

Vertex Table Primary Contains the set of explored vertices with vertex table primary key.
Key

Component Component index column name (default: “COMPONENT”)

3.2.5.4.3.5 Pattern Matching


Pattern matching is a kind of graph query, which involves finding all the subgraphs (within a graph) that match
the given pattern.

The graphical calculation view editor in the SAP Web IDE provides two approaches to model calculation views
with graph nodes that help execute graph pattern queries. In the first approach, you can use the graphical
pattern matching editor to create and execute graph pattern queries. In the second approach, describe the
pattern in the openCypher query language (Cypher is a registered trademark of Neo Technology, Inc.) within
the graph node and execute them.

Pattern Matching with Graphical Pattern Editor

The graphical pattern editor lets you visually compose pattern matching queries, execute them, and visualize
the results.

The graphical pattern contains a set of vertex variables, a set of edge variables, a set of filter conditions, a
projection list, an order-by list, a limit, and an offset.

The result of the graphical pattern matching query is a projection of subgraphs within a given graph workspace
that matches the given pattern. The columns of the result table correspond to the projection list of the given
pattern. Every row in the result table corresponds to a matching subgraph.

In the editor, choose + to add a new vertex. After adding vertices to the editor, select a vertex and choose

to create an edge.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 69
Pattern Matching with openCypher Query Language

The pattern matching action with the openCypher query language enables you to execute pattern matching
queries on the given graph workspace. You write these queries in the supported subset of the openCypher
query language

expression A query string written in the supported subset of the Cypher


query language containing one MATCH clause and one
RETURN clause.

The output includes the following:

result table Every row corresponds to a matching subgraph. Every row


contains attributes of vertices and edges specified in the
RETURN clause.

In the editor, choose Generate Column to define the output columns of the graph node. The tool includes the
columns in the RETURN clause as the output columns of the graph node.

 Note

For more information on openCypher Query language, see the SAP HANA Graph Reference guide.

3.2.5.5 Use Intersect Set Operation

Use the intersect view node in calculation views to perform intersect set operations on two data sources.

Context

Intersect set operations on data sources in calculation views help retrieve rows that are common to both the
data sources. The tool supports performing intersect set operations only for two data sources at a time. After
performing the intersect set operation, you can use the result of the intersect set operation as inputs to other
view nodes.

For example, you can perform intersect set operations on SALES_2016 and SALES_2017 to identify the subset
of products sold during both, 2016 and 2017.

 Note

You can perform intersect operation only if both the data sources have same number of fields with
matching data types.

SAP HANA Modeling Guide


70 PUBLIC Creating a Graphical Calculation View
Procedure

1. Open the required calculation view in the view editor.


2. From the tool palette of the editor, drag and drop an intersect view node to the editor.
3. Add data sources.

 Note

You must have two data source in the intersect view node.

a. Select the intersect view node.

b. Choose (Add Data Source).


c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.
d. Choose Finish.
4. Define output columns.

a. In the editor toolbar, choose (Expand Details Panel).


b. On the Mapping tab, select the columns you want to add to the output of the intersect view node.
c. In the context menu, choose Add To Output.

 Note

If you want to add all columns of a data source to the output, in the context menu of the data
source, choose Add To Output.

5. (Optional) Create constant output columns.


Create new output columns and assign it with constant values.
a. Choose the Mapping tab.
b. In the Output Columns section, choose + (Create Constant).
c. In the Create Target and Manage Mapping dialog box, provide a name for the new constant output
column.
d. Provide the required data type, length, and scale values.
e. In the Source Column dropdown list, select the required column from the data source with which you
want to map the constant output column.
f. In the Constant Value text field, provide the required constant value.
g. Select is Null checkbox, if you want to assign a null value to the constant output column.

 Note

If you do not provide any constant value, then the tool, by default, considers the constant output
column value as null.

h. Choose OK.
6. (Optional) Define calculated columns.
a. Choose the Calculated Columns tab.
b. Choose + (Add).
c. Select and expand the new calculated column.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 71
d. Define the calculated column.
7. (Optional) Define input parameters or variables.
a. Choose the Parameters tab.

b. Choose (Add).
c. Select Input Parameter or Variable menu option.
d. Select and expand the new input parameter or variable.
e. Define the input parameter or variable.
8. Add result as inputs to other view nodes.
a. In the view editor, select the intersect view node.

b. Choose .
c. Drag the cursor to the view the node for which you want to provide the input.

Related Information

Create Calculated Columns [page 99]


Assign Variables [page 107]
Create Input Parameters [page 112]

3.2.5.6 Use Minus Set Operation

Use the minus view node in calculation views to perform minus set operations on two data sources.

Context

Minus set operations on data sources help first retrieve all rows from the first data source, and then removes all
rows that appear in the result set of the second data source. The tool supports performing minus set
operations only for two data sources at a time. After performing the minus set operation, you can use the result
of the set operation as inputs to other view nodes.

For example, you can perform minus set operations on SALES_2017 and SALES_2016 to identify those
products that were sold in 2017, but not in the year 2016.

 Note

The results of the minus set operations are dependent on the order of the data sources in the minus view
node, and you can perform minus operation only if both the data sources have same number of fields with
matching data types.

SAP HANA Modeling Guide


72 PUBLIC Creating a Graphical Calculation View
Procedure

1. Open the required calculation view in the view editor.


2. From the tool palette of the editor, drag and drop a minus view node to the editor.
3. Add data sources.
You must have two data source in the minus view node.
a. Select the minus view node.

b. Choose (Add Data Source).


c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.
d. Choose Finish.
If you want to switch the order of the data sources in the node, right-click the minus view node and
choose Switch Order.
4. Define output columns.

a. In the editor toolbar, choose (Expand Details Panel).


b. On the Mapping tab, select the columns you want to add to the output of the minus view node.
c. In the context menu, choose Add To Output.

 Note

If you want to add all columns of a data source to the output, in the context menu of the data source,
choose Add To Output.

5. (Optional) Create constant output columns.


Create new output columns and assign it with constant values.
a. Choose the Mapping tab.
b. In the Output Columns section, choose + (Create Constant).
c. In the Create Target and Manage Mapping dialog box, provide a name for the new constant output
column.
d. Provide the required data type, length, and scale values.
e. In the Source Column dropdown list, select the required column from the data source with which you
want to map the constant output column.
f. In the Constant Value text field, provide the required constant value.
g. Select is Null checkbox, if you want to assign a null value to the constant output column.

 Note

If you do not provide any constant value, then the tool, by default, considers the constant output
column value as null.

h. Choose OK.
6. (Optional) Define calculated columns.
a. Choose the Calculated Columns tab.
b. Choose + (Add).
c. Select and expand the new calculated column.
d. Define the calculated column.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 73
7. (Optional) Define input parameters or variables.
a. Choose the Parameters tab.

b. Choose (Add).
c. Select Input Parameter or Variable menu option.
d. Select and expand the new input parameter or variable.
e. Define the input parameter or variable.
8. Add result as inputs to other view nodes.
a. In the view editor, select the minus view node.

b. Choose .
c. Drag the cursor to the view the node for which you want to provide the input.

Related Information

Create Calculated Columns [page 99]


Assign Variables [page 107]
Create Input Parameters [page 112]

3.2.5.7 Use Hierarchy Functions

Users can model calculation views with hierarchy function view nodes that allow them to use several SAP
HANA hierarchy functions in the view definition. The hierarchy functions typically help work with hierarchical
data.

Context

The hierarchy function view nodes enable you to use the hierarchy generator functions to generate hierarchies
and to use the hierarchy navigation functions on the generated hierarchies to efficiently compute ancestors,
descendants, or siblings of nodes.

The tool supports using the following functions in the hierarchy function view nodes.

Generator Functions Description

Hierarchy Function Generates a hierarchy based on recursive parent-child source data.

Hierarchy Leveled Generates a hierarchy based on source data that has a leveled format.

Hierarchy Span Tree Generates a hierarchy for a recursive parent-child source containing only the first
shortest path between each start and result node.

SAP HANA Modeling Guide


74 PUBLIC Creating a Graphical Calculation View
Generator Functions Description

Hierarchy Temporal Generates a time-dependent hierarchy for recursive parent-child source data whose
edges are additionally qualified by validity intervals.

Navigation Functions Description

Hierarchy Ancestors This function helps navigate all ancestors of a set of start nodes in a hierarchy.

Hierarchy Descendants This function helps navigate all descendants of a set of start nodes in a hierarchy.

Hierarchy Siblings This function helps navigate all siblings of a set of start nodes, including the start
nodes.

Related Information

Hierarchy Data Model


Hierarchy Terminology

3.2.5.7.1 Generate Hierarchies

Use built-in hierarchy generator functions that SAP provides to translate the diverse relational source data into
hierarchies that can be represented in a generic and normalized tabular format.

Context

The structure of a hierarchy generated from a hierarchy function is always the same, regardless of the original
format of the source data, and consists of an ordered list of its nodes. The nodes themselves are represented
by a minimal set of orthogonal hierarchy topology attributes plus a projection of the original source attributes.

Procedure

1. Open the required calculation view in the view editor.


2. From the tool palette of the editor, drag a hierarchy function view node to the editor.
3. Add data sources.
a. Select the hierarchy function view node.

b. Choose (Add Data Source).

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 75
c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.
The hierarchy is generated from the data source that you select. You can add only one data source in
the hierarchy view node.
d. Choose Finish.
4. Select a hierarchy generator function and define values.
a. In the details pane, select the Definition tab.

b. Choose .
c. Select Generator.
d. Select the required hierarchy function that you want to use to generate the hierarchy.
5. (Optional) Concatenate multi-column tuple-like node identifiers into single scalar values.
You can combine two or more scalar expressions into a single value for use as a unique, reliable value by
hierarchy generator functions. The resulting values have additional characters encoding the lengths of the
components to ensure uniqueness within the results.
a. Select the Enable Multidefinition checkbox.
b. Select the attribute columns that define parent-child relationships.
6. Provide values to generate the hierarchy.

Generator Func­
Property Value tions

Parent In the value help list, select an attribute column in the data source that specifies Hierarchy Func­
the PARENT_ID (parent). tion, Hierarchy
Span Tree, Hier­
archy Temporal

Child In the value help list, select an attribute column in the data source that specifies Hierarchy Func­
the NODE_ID (node). tion, Hierarchy
Span Tree, Hier­
archy Temporal

Level In the Define Levels pane, choose + to select one more attribute columns that Hierarchy Lev­
specifies the levels. eled

Start The start condition helps identify the root nodes. Use the expression editor to Hierarchy Func­
specify the start condition as an expression. tion, Hierarchy
Span Tree, Hier­
 Remember archy Temporal

The start condition is applied as an additional filter on the data source. If a


start condition is not specified, then root nodes are identified by the condi­
tion WHERE PARENT_ID IS NULL.

Depth The depth can be a fixed value or an input parameter. It specifies the maximum Hierarchy Func­
search depth during hierarchy generation. tion, Hierarchy
Span Tree, Hier­
archy Temporal

Valid From and In the value helps list, select the attribute columns that provides the required Hierarchy Tem­
Valid To validity intervals. You can provide a fixed value from selected attribute columns poral
or use an input parameter to specify the validity intervals.

SAP HANA Modeling Guide


76 PUBLIC Creating a Graphical Calculation View
Generator Func­
Property Value tions

Orphan Handling In the dropdown list, select a value that specifies the orphan handling policies. Hierarchy Func­
○ Ignore: Orphans are silently ignored and is the default behavior. tion

○ Error: If the input data contains any orphans, then an error is raised.
 Note
○ Root Node: Top-level orphans are treated as root nodes.
○ Adopt: Top-level orphans are adopted as children of the last root behind its
regular descendants.

Cache Orphans are always ignored for Hierarchy Span Tree, Hierarchy Temporal, and Hierarchy Func­
Hierarchy Leveled generatorIn the dropdown list, select a value that specifies the tion, Hierarchy
caching policy for the generated hierarchy.Orphans are always ignored for Hier­ Span Tree, Hier­
archy Temporal,
archy Span Tree, Hierarchy Temporal, and Hierarchy Leveled generator func­
Hierarchy Lev­
tions.
eled
○ Cache: The generated hierarchy is cached if the system assesses the source
to be reliably deterministic. Cache is the default behavior.
○ Do not Cache: The generated hierarchy is not cached.
○ Force Cache: The generated hierarchy is cached even if the source cannot
be assessed to be reliably deterministic.

Cache helps improve the subsequent navigation of the same hierarchy.

Siblings Order In the Siblings Order By pane, choose + to use one or more output columns of Hierarchy Func­
By the view node to SIBLING ORDER BY and sort the output sibling nodes. In tion, Hierarchy
Span Tree, Hier­
the Sort Direction dropdown list, select the required sort direction.
archy Temporal,
Hierarchy Lev­
eled

7. Define output columns.


If required, you can add one or more columns from the data source as output columns to the view node.

a. In the editor toolbar, choose (Expand Details Panel).


b. On the Mappings tab, select the columns you want to add to the output of the hierarchy function view
node.

 Note

Some default attributes are calculated by the hierarchy generator function and are part of the
output columns. You cannot edit them.

c. In the context menu, choose Add To Output.

 Note

If you want to add all columns of a data source to the output, in the context menu of the data
source, choose In the value help list, select an attribute column in the data source that specifies
the PARENT_ID (parent).In the value help list, select an attribute column in the data source that
specifies the PARENT_ID (parent).nullnullnullnullAdd To Output.

8. (Optional) Define input parameters or variables.


a. Choose the Parameters tab.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 77
b. Choose (Add).
c. Select Input Parameter or Variable menu option.
d. Select and expand the new input parameter or variable.
e. Define the input parameter or variable.
9. Add result as inputs to other view nodes.
After creating a hierarchy function view node to generate hierarchies, you can use hierarchy generator
function results as inputs to other view nodes. For example, you can use the generated hierarchy as inputs
to other hierarchy functions view nodes that are defined with hierarchy navigation functions.
a. In the view editor, select the hierarchy function view node.

b. Choose .
c. Drag the cursor to the view node for which you want to provide the input.

Related Information

HIERARCHY Generator Function


Basic Attributes

3.2.5.7.2 Navigate Hierarchies

SAP HANA provides built-in navigation functions that use optimized algorithms on the hierarchy attributes to
efficiently compute ancestors, descendants, or siblings of nodes.

Context

Complex calculations on the hierarchy involving a start set of nodes and potentially multiple steps beyond their
immediate neighborhood are termed navigations.

Procedure

1. From the tool palette of the editor, drag a hierarchy function view node to the editor.
2. Add inputs to the view node.
a. Add a hierarchy for the navigator function to operate on.
To add, use the result of a hierarchy generator function as input to this view node.

 Remember

The hierarchy generator result must contain all the basic hierarchy attributes computed by a
hierarchy generator function.

SAP HANA Modeling Guide


78 PUBLIC Creating a Graphical Calculation View
b. (Optional) Add an additional input table or a data source with a filter condition that specifies the start
nodes.
This means that, input to the hierarchy function view node must contain, at minimum, a column
named or aliased as START_RANK that has a data type that can be cast to BIGINT. If the start nodes
are not specified, then the navigation starts from all nodes in the hierarchy.
3. Specify the hierarchy generator.
If you are specifying the start node as an additional input table or a filter condition on a data source, then
also specify which of the two inputs in the view node is a hierarchy generator function.
a. In the details pane, select the Mapping tab.
b. In the Data Sources pane, select a data source that is a hierarchy generator.
c. In the Properties section, set the value of Type as Generator.
4. Select the required navigation function.

a. In the editor toolbar, choose (Expand Details Panel).


b. In the details pane, select the Definition tab.

c. Choose .
d. Select Navigation and choose a menu option.

Menu Option Description

Hierarchy Ancestors Lists all ancestors of a set of start nodes in a hierarchy.

Hierarchy Descendants Lists all descendants of a set of start nodes in a hierarchy

Hierarchy Siblings Lists all siblings of a set of start nodes, including the start nodes.

 Remember

If the start nodes are not specified, then the navigation starts from all nodes in the hierarchy.

5. Provide values to navigate the hierarchy.

Navigation Func­
tion Property Value

Distance Specify a scalar integer value as minimum HIERARCHY_DISTANCE. You can pro­
Hierarchy Ances­ From vide a fixed value or use an input parameter to provide the value at runtime.
tor
Distance To Specify a scalar integer value as maximum HIERARCHY_DISTANCE. You can pro­
vide a fixed value or use an input parameter to provide the value at runtime.

The Distance From and Distance To values for Hierarchy Ancestor function is al­
ways less than or equal to 0.

Start Rank (Optional) In the value help list, select a START_RANK column that has a data type
that can be cast to BIGINT.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 79
Navigation Func­
tion Property Value

Distance Specify a scalar integer value as minimum HIERARCHY_DISTANCE. You can pro­
Hierarchy De­ From vide a fixed value or use an input parameter to provide the value at runtime.
scendants
Distance To Specify a scalar integer value as maximum HIERARCHY_DISTANCE. You can pro­
vide a fixed value or use an input parameter to provide the value at runtime.

The Distance From and Distance To values for Hierarchy Descendants function is
always greater than or equal to 0.

Start Rank (Optional) In the value help list, select a START_RANK column that has a data type
that can be cast to BIGINT.

Hierarchy Siblings Start Rank (Optional) In the value help list, select a START_RANK column that has a data type
that can be cast to BIGINT.

6. Define output columns.


a. On the Mappings tab, select the columns you want to add to the output of the hierarchy function view
node.

 Note

Some default attributes are calculated by the hierarchy generator function. The navigation function
projects all default attributes calculated by the source hierarchy generator function plus a lateral
projection of the corresponding START record. You must retain all of them as the output columns
of this view node and cannot edit them.

b. In the context menu, choose Add To Output.

 Note

If you want to add all columns of a data source to the output, in the context menu of the data
source, choose Add To Output.

7. (Optional) Define input parameters or variables.


a. Choose the Parameters tab.

b. Choose (Add).
c. Select Input Parameter or Variable menu option.
d. Select and expand the new input parameter or variable.
e. Define the input parameter or variable.
8. Add result as inputs to other view nodes.
After creating a hierarchy function view node to navigate hierarchies, you can use hierarchy navigation
function results as inputs to other view nodes. For example, if you want to project only some of the output
columns to calculation view output, then you can use the result of this view node in a projection view node
to project only the required columns as output columns of the calculation view.
a. In the view editor, select the hierarchy function view node.

b. Choose .

SAP HANA Modeling Guide


80 PUBLIC Creating a Graphical Calculation View
c. Drag the cursor to the view node for which you want to provide the input.

Related Information

Navigating Hierarchies
HIERARCHY_ANCESTORS Navigation Function
HIERARCHY_DESCENDANTS_AGGREGATE Navigation Function
HIERARCHY_SIBLINGS Navigation Function

3.2.5.8 Anonymize Data Using Calculation Views

Use the anonymization capabilities in SAP HANA to anonymize calculation view output. Anonymization
methods help gain statistically valid insights from your data while protecting the privacy of individuals.

Context

SAP HANA supports the methods k-anonymity and differential privacy. To attain the anonymization
capabilities, the graphical calculation view editor provides an anonymization view node. You can use this view
node to select the required anonymization method and to define the level of privacy for a data set.

Procedure

1. Open the required calculation view in the view editor.


2. From the tool palette of the editor, drag and drop an anonymize view node to the editor.
3. Add data sources.
a. Select the anonymize view node.

b. Choose (Add Data Source).


c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.

 Note

You can add only one table or one view as a data source in an anonymization view node. You can
also use other view nodes (join, projection, aggregation, and so on) as inputs to the anonymize
view node, provided you are using only tables or views as data sources.

 Restriction

Do not use input parameters in any of the expressions below the anonymize view nodes.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 81
d. Choose Finish.
4. Define output columns.

a. In the editor toolbar, choose (Expand Details Panel).


b. On the Mapping pane, select the columns you want to add to the output of the anonymize view node.
c. In the context menu, choose Add To Output.

 Note

If you want to add all columns from the data source to the output, in the context menu of the data
source, choose Add To Output.

5. Select an anonymization method.


Select an anonymization method that you want to use to anonymize the calculation view output.

a. In the Details tab, choose .


b. Select the required anonymization method.
SAP HANA supports the methods k-anonymity and differential privacy.

Anonymization Method Description

k-anonymity k-anonymity is an intuitive and widely used method for modifying data for pri­
vacy protection. k-anonymity anonymizes data by generalizing the individual
record in a group of similar records, thus significantly reducing the possibility
that the individual can be identified.

Differential Privacy Differential privacy anonymizes data by randomizing sensitive information but
in a way that regardless of whether an individual record is included in the data
set or not, the outcome of statistical queries remains approximately the same.
Differential privacy provides formal statistical privacy guarantees.

6. (Optional) Define input parameters or variables.


a. Choose the Parameters tab.

b. Choose (Add).
c. Select Input Parameter or Variable menu option.
d. Define the input parameter or variable.
7. Add result as inputs to other view nodes.
a. In the view editor, select the anonymization view node.

b. Choose .
c. Drag the cursor to the view node for which you want to provide the input.

Next Steps

For more information on Anonymization also see, SAP HANA Data Anonymization in the SAP HANA Security
Guide for SAP HANA Platform.

SAP HANA Modeling Guide


82 PUBLIC Creating a Graphical Calculation View
Related Information

Configure k-Anonymity [page 83]


Configure Differential Privacy [page 85]

3.2.5.8.1 Configure k-Anonymity

In the anonymization view node definition, configure parameters and provide values based on the selected
anonymization method.

Procedure

1. In the Sequence Column dropdown list, select a value.


The tool populates the values in the dropdown list based on the output columns of the anonymization view
node. The data type of sequence columns (seq column) are INT and BIGINT only.
2. In the k text field, define the required k-value.
The k value is the minimum number of distinct values in the generalization hierarchy of a Quasi-identifying
information column.
3. In the Loss text field, enter the required loss value.
The loss parameter helps specify the proportion of records that can be dropped from the results in order to
limit the extent of generalization.
4. In the Quasi Columns pane, choose + to define columns that contain the quasi identifying information.
5. For each column and for every distinct column value define the generalization hierarchies.
You can define new generalization hierarchies, or use an external calculation view to define the
generalization hierarchies.
6. If you want to define a new generalization hierarchy, select a column and choose >.
a. For the selected column, if you want to import all distinct column values to the editor, choose Import
Values.

b. If you want to add a new row, in the Details pane, choose (Add Row).

Adding new row helps add a new column value to the generalization hierarchy.
c. If you want to add a new hierarchy level to the column value, in the Details pane select the column value

and choose (Add Level).

For each distinct column value, you can add one or more levels and define an hierarchy structure level-
by-level. You can also copy and reuse the hierarchy definition of a selected column value to another
column value.

 Remember

Use only string values to define the levels. The value for the last level is always *.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 83
7. If you want to copy the hierarchy definition, in the Details pane select a column value and choose (Copy
Hierarchy)

If you want to reuse this copied definition to one or more column value, select the new column values and

choose (Paste Hierarchy).


8. Choose Back to go back and save the generalization hierarchy definition.
9. If you want to use an external calculation view to define the generalization hierarchy, then in the
Generalization Hierarchies dropdown list, choose External.
a. In the Column Hierarchy value help, select the calculation view that provides the generalization
hierarchy definition.
10. In the Weight textfield, enter the required value.
By weighting one or more columns in your definition of k-anonymity, you can adjust the relative importance
of different attributes. This allows you to to influence the data quality after generalization in the quasi-
identifying columns.
11. In the Min Level text field, enter the required value.
You can restrict the possible generalization levels of quasi-identifying columns by setting a minimum value.
12. In the Max Level text field, enter the required value.
You can restrict the possible generalization levels of quasi-identifying columns by setting a maximum
value.

Related Information

Example: Sequence Column [page 84]

3.2.5.8.1.1 Example: Sequence Column

Sequence column is a column that represents the sequence for the data set. It helps distinguish new and
inserted data.

The sequence column is a user defined field containing (INT or BIGINT) integers of the input table. It follows
these rules:

● Rule 1: Each row in squence column is a unique value.


● Rule 2: It is monotonic increasing. This means that, same values are not set twice even though they are
note present anymore.
● Rule 3: Values are always greater than zero.
● Rule 4: Each individual is only once in the table.

Example

Assume the following table

SAP HANA Modeling Guide


84 PUBLIC Creating a Graphical Calculation View
SeqCol Sickness

1 Cough

2 Cancer

If a new value is inserted, it gets a new unique sequence column value. (Following Rule 1)

SeqCol Sickness

1 Cough

2 Cancer

3 AIDS

Now assume we delete an entry

SeqCol Sickness

1 Cough

3 AIDS

and insert another entry. In this case, we choose "4" as the next sequence entry. (Following Rule 2)

SeqCol Sickness

1 Cough

3 Cancer

4 Broken Legs

 Note

The user is responsible for the maintenance of this column. In the calculation view editor, we only require a
reference to this column.

3.2.5.8.2 Configure Differential Privacy

In the anonymization view node definition, configure parameters and provide values based on the selected
anonymization method.

Procedure

1. In the Sequence Column dropdown list, select a value.


The tool populates the values in the dropdown list based on the output columns of the anonymization view
node. The data type of sequence columns (seq column) are INT and BIGINT only.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 85
2. In the Epsilon text field, enter the required values.
This is the value epsilon (ɛ). Typical values are 0.1 or 0.01. However, for some use cases, setting epsilon to a
value larger than 1, for example 5, is fine as well. eε is the maximum multiplicative impact on the probability
of any outcome. The lower the value of epsilon, the greater the privacy required and the more noise is
applied.
3. In the Sensitivity text field, enter the required values.
Sensitivity is typically range of values. Choosing the correct sensitivity is necessary to guarantee
differential privacy. Setting the sensitivity higher than necessary will reduce the quality of the anonymized
data.
4. In the Noised Column dropdown list, select the required column value.
The data types of noised columns are FLOAT or DOUBLE only.

3.2.5.9 Model Table Functions as View Nodes

Use table function view nodes to model table functions with both tabular input parameters and scalar input
parameters. These view nodes help provide mappings to inputs of table function.

Context

Table functions are user-defined functions that accepts multiple inputs, but returns exactly one result table.
The inputs are scalar inputs or table type inputs.

You can use a table function as a data source directly within a view node (for example, a projection view node,
aggregation view node, and more). But, with SAP HANA 2.0 SPS 01 onwards, you can also use the new table
function view node to model table functions with both, tabular input parameters and scalar input parameters.

In table function view nodes, you can add a table function type, and use other data sources or output of other
view nodes to fill the tabular input parameters of the table function. You can create input parameters or
constants in the table function view node to fill the scalar input parameters of the table function.

After modeling a table function, you can use the output of the table function as inputs to other view nodes in
the calculation view.

Procedure

1. Open the required calculation view in the view editor.


2. From the tool palette of the editor, drag a table function view node to the editor.
3. Add a table function as a data source.
Have at least one table function type in the table function view node. The table function inputs the table
type definition along with its columns and scalar parameters.
a. Select the table function view node.

SAP HANA Modeling Guide


86 PUBLIC Creating a Graphical Calculation View
b. Choose (Add Table Function).
c. In the Find Data Sources dialog box, enter the name of the table function and select it from the list.
d. Choose OK.
4. Add data sources.
Add tables (data sources) that provides inputs to the table function. You can also add a view node from the
calculation view as an input to the table function view node.
a. Select the table function view node.

b. Choose (Add Data Source).


c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.
d. Choose Finish.
5. Define input columns.
Map the columns and parameters from the data source with columns and scalar parameters of the table
function respectively.

a. In the editor toolbar, choose (Expand Details Panel).


b. Choose the Input Mapping tab.
c. Select the required column from the data source that you want to add as input columns to the table
function.
d. Drag the cursor to the Input Table Type columns.

 Note

Map columns with matching data types.

6. (Optional) Create constants


Create new input columns and assign it with constant values. You can map constants with scalar input
parameters of the table function.
a. Choose the Input Mapping tab.

b. Choose (Create Constant).


c. Enter a constant value.
d. Choose OK.
7. (Optional) Define input parameters or variables.
You can create both input parameters and variables within the table function view node. But, you can map
only input parameters with scalar input parameters of the table function.
a. Choose the Parameters tab.

b. Choose (Add).
c. Select Input Parameter or Variable menu option.
d. Select and expand the new input parameter or variable.
e. Define the input parameter or variable.
8. Add result as inputs to other view nodes.
You can see the output columns of the table function view node in the Columns tab.
a. In the view editor, select the table function view node.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 87
b. Choose .
c. Drag the cursor to the view the node for which you want to provide the input.

Related Information

Create Input Parameters [page 112]


Assign Variables [page 107]

3.2.5.10 Filter Output of View Nodes

Apply filters on columns of view nodes to filter their output.

Context

For example, you could apply filters to retrieve sales of a product where (revenue >= 100 AND region = India)
OR (revenue >=50 AND region = Germany). You can also define filters using nested or complex expressions.

Filters on columns are equivalent to the HAVING clause of SQL. Filters help optimize the calculation view
execution. At runtime, the system executes the filters after performing all the operations defined in the lower
view nodes.
You can define filters on columns using a filter expression, and can use the column engine language or the SQL
language to define the filter expression.

Procedure

1. Open the required calculation view in the view editor.


2. Select a view node.

 Note

You cannot apply filter on output columns of the graph nodes, table function view nodes, non-equi join
view nodes, anonymize view nodes, or hierarchy function view nodes of a calculation view.

3. Filter output of a view node.


Apply filters on output columns of a view node to filter its output results.

a. In the editor toolbar, choose (Expand Details Panel).


b. Choose the Filter Expression tab.
c. In the Language dropdown list, select the required language.

SAP HANA Modeling Guide


88 PUBLIC Creating a Graphical Calculation View
d. In the expression editor, enter the expression that defines the required filter conditions.
Use the elements, functions, and operators in the Filter Expression tab to build your expression.
For example,

(revenue >= 100 AND region = India) OR (revenue >=50 AND region = Germany)

 Tip

In the expression editor, the tool provides hints for all supported functions. The hints give you more
information on the functions, its purpose, and syntax.

4. (Optional) Ignore multiple outputs.


If you have modeled a calculation view in which you are using the same view node as an input to multiple
other view nodes, you can push down the filters defined in the top node to the lower nodes at execution.
a. Select the view node that is used as inputs in multiple view nodes.
b. Choose the Mapping tab.
c. In the Properties section for the view node, select the Ignore Multiple Output for Filters checkbox.

 Note

Ignore multiple output is described with this example.

If you have defined a filter in ViewNode_1, the default behavior of the engine is to not push down the
filters to the lower nodes (ViewNode_3). This behavior is to avoid any impact to results of ViewNode_2.
You can override this behavior by setting the Ignore Multiple Output for Filters flag in ViewNode_3.
Setting this flag pushes down the filter defined in ViewNode_1 to ViewNode_3.

5. (Optional) Handling filters for calculation views with rank nodes.


If you have modeled a calculation view with a rank node as an input to any of the top nodes, and if you have
defined a filter on the top node, you can push down the filter to nodes below the rank node at execution.
a. Select the rank node.
b. Choose the Mapping tab.
c. In the Properties section of the rank node, choose Allow Filter Push Down.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 89
3.2.5.10.1 Filter Using Fuzzy Search Parameters

The calculation view editor enables you to create and use fuzzy search parameters to filter attribute columns in
the projection view nodes.

Context

In the fuzzy search parameter definition, you define the fuzzy search string and the required fuzzy score. Fuzzy
search is a fast and fault-tolerant search feature for SAP HANA. A fuzzy search returns records even if the
search term contains additional or missing characters or other types of spelling errors.

For example, you can create a fuzzy search parameter FP with confidence as 0.8 and default search string as
Softwar, and apply the search parameter on the attribute column, CATEGORY. At runtime, the SQL query
includes a placeholder, "$$FP$$"=>'Softwar', and as a result, it returns data for the category values as
Software, Softwares, Softwar, and similar.

Procedure

1. Open the required calculation view in the view editor.


2. Double-click the view node in which you want to define the fuzzy search parameters.

3. In the Parameters tab, choose .


4. Choose the Fuzzy Search Parameter menu option.
5. Select and expand the new fuzzy search parameter.
6. Define the fuzzy search parameter.
You can define more than one fuzzy search parameter for a calculation view.
a. In the Name text field, provide a name for the parameter.
b. In the Default Search String textbox, enter the required search string.
c. In the Confidence text field, enter the required fuzzy score.

You can either use a fixed value between 0 to 1 as the fuzzy score, or use an input parameter to define
the fuzzy score value at runtime. In the value help, choose the required type with which you want to
provide the fuzzy score value.
7. Select attribute columns.
Select the attribute columns on which you want to perform the fuzzy search. The tool filters and projects
the attribute column values based on the search string and the fuzzy score defined in the fuzzy search
parameter.

 Note

You can perform fuzzy search only for attribute columns in the projection view nodes. In addition, you
can perform fuzzy search only on tables as data sources. This means that, the selected projection view
node must have only tables as the data source.

SAP HANA Modeling Guide


90 PUBLIC Creating a Graphical Calculation View
a. Double-click the required projection view node in which you want to assign the parameters.
b. In the details pane, choose the Fuzzy Search Filter tab.
c. Select the required fuzzy search parameter and the corresponding attribute column on which you
want to perform the fuzzy search.
You can use the value help to select one or more attribute columns. If you have selected more than one
attribute column, then the tool performs a logical OR of all attribute columns.
d. Choose + to assign another fuzzy parameter to the same or different attribute columns.
If you have assigned more than one fuzzy search parameter to the same attribute column, then the
tool performs a logical AND of all parameters.

3.2.6 Supported Data Categories for Calculation Views

The tool supports three types of data categories to classify calculation views. The following table explains each
of these data category types.

Data Category Description

Cube Calculation views with data category Cube are visible to the reporting tools and support data analysis
with multidimensional reporting.

For graphical calculation views with data category as Cube, the tool provides aggregation as the default
view node. Also, an additional aggregation column behavior is available that you can use to specify the
aggregation types for measures.

Dimension Calculation views with a data category Dimension are not visible to the reporting tools and do not sup­
port data analysis. However, you can use these calculation views as data sources in other calculation
views for any multidimensional reporting purposes.

If the data category is Dimension, you cannot create measures. You can only consume them with SQL.
For example, you can use such calculation views to fill simple-list user interfaces, where recurring at­
tribute values are not a problem, but are desired. The output node offers only attributes of numerical
data types.

For graphical calculation views with data category Dimension, the tool provides projection as the default
view node.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 91
Data Category Description

SQL Access Only Calculation views with data category SQL Access Only are not visible to the reporting tools and do not
support multidimensional reporting.

However, you can use these calculation views as data sources in other calculation views for any multidi­
mensional reporting purposes.

For graphical calculation views with data category SQL Access Only, the tool provides projection as the
default view node.

If you change the data category of the view from CUBE or DIMENSION to SQL ACCESS ONLY and if the
view is directly accessed by a front end tool, then validate whether your front-end tool can still report on
the respective view.

 Note
Do not change to data category "SQL ACCESS ONLY" if you have explicitly modeled hierarchies in
the Semantics node. For more information, see 2821857

Related Information

Create Graphical Calculation Views [page 10]

3.2.7 Example: Using Keep Flag

Using keep flag for an attribute column helps in ensuring that calculations occur at a granularity, and that it
includes the attributes flagged as "Keep".

The keep flag property for attribute columns influence the result set of a calculation view.

When to Use the Keep Flag

You use the keep flag property when the level of granularity has an impact on the outcome of a measure. This
means that, you use keep flag for attribute columns whenever the order matters for executing the calculations
and aggregations.

For example, consider the expression, a⊕b + c⊕d ≠ (a+c) ⊕ (b+d), where ⊕ is an operator:

In this expression: If ⊕ = +, then the keep flag property is not relevant because, a+b+c+d = (a+c)+(b+d).

But, in the expression, if ⊕ = *, then the keep flag property is relevant. a*b+c*d ≠ (a+c)*(b+d)=a*b+a*d+c*b
+c*d.

SAP HANA Modeling Guide


92 PUBLIC Creating a Graphical Calculation View
Example

The following is an example where order of execution matters. Different results occur depending on whether
the aggregations are executed first, or if the calculations are executed before the aggregations.

Day Value1 Value2

1 2 3

1 3 4

2 1 3

Scenario 1: Aggregate on the day level and then multiply.

Day Value1 Value2 Multiplied

1 5 7 35

2 1 3 3

Scenario 2: First multiply and then aggregate on the day level.

Day Value1 Value2 Multiplied

1 2 3 6

1 3 4 12

2 1 3 3

For scenario 2, the aggregation results is,

Day Value1 Value2 Multiplied

1 5 7 18

2 1 3 3

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 93
3.3 Preview Calculation View Output

After modeling calculation views based on your requirements, you can deploy them and preview its output from
within the same tool.

Context

The tool provides multiple preview options. You can preview output data of calculation views in simple tabular
format, or you can preview output data in graphical representations such as, bar graphs, area graphs, and pie
charts. If your calculation view is defined with hierarchies, then the tool allows you to preview the output data in
hierarchical representations.

You can also export and download the output data to .csv files. The tool also allows you to preview the SQL
query that the tool executed to fetch the output data.

Procedure

1. Start SAP Web IDE in a Web browser.


2. In the Workspace view, select the required calculation view to preview its output.
3. In the context menu, choose Data Preview.
4. Provide input parameter or variable value.
If you have defined any input parameters in the calculation view, provide the required input parameter
values.
a. Select the required operator.
b. Provide values for the From and To fields based on the selected operator.

c. In the toolbar, choose (Open Content).


In the Raw Data tab, the tool displays the output data in tabular format.
5. (Optional) Apply filters.

a. If you want to apply filters on columns and preview the filtered output data, in the toolbar, choose
(Add Filter).
b. Choose Add Filters.
c. Select the required columns and define the filter conditions.
d. Choose Apply.
6. Export output data, if required.
If you want to export the raw data output to a .csv file,

a. In the toolbar, choose (Download).


b. In the Delimiter dropdown list, select the required delimiter that the tool must use to separate the
values in the .csv file.

SAP HANA Modeling Guide


94 PUBLIC Creating a Graphical Calculation View
c. Choose Download.
7. View SQL query for the calculation view, if required.
a. If you want to view the SQL query that the tool executed to fetch the data, in the toolbar, choose SQL.

b. In you want to view, edit and execute the SQL query in SQL editor, choose (Edit SQL
Statement in SQL Console).
8. Preview output of calculation views in graphical representations.
The tool supports bar graph, area graph, pie chart and table charts, and other graphical representations to
preview the output of a calculation view. These graphical representations allow more detailed analysis of
output data.
a. In the menu bar, choose Analysis.
b. Configure the axis values by dragging and dropping the required attributes and measures to the Label
Axis and the Value Axis.
The tool displays the output data in graphical representation. Select the required chart icons in the
menu to view the output in different graphical representation.

c. In the toolbar, choose (Display Settings) to toggle legends and values.


d. If you want to view the query SQL query that the tool executed to fetch the data for the provided axes
configurations, in the toolbar, choose SQL.

e. If you want to export the charts as .png files to your local system, in the toolbar, choose (Download)
and select Chart.

f. If you want to export the raw output data as .csv files to your local system, in the toolbar, choose
(Download) and select Data.
9. Preview output of hierarchies.
The SAP Database explorer provides a Hierarchies tab to preview output of calculation views that contain
hierarchies. If you have defined any hierarchies in calculation views of type Dimension or Cube, you can
preview output in hierarchical tree structures.

 Note

The tool does not support preview output of compound parent-child hierarchies in calculation views.

a. In the menu bar, choose the Hierarchies tab.


In the Available Objects pane, the tool displays all hierarchies defined in the calculation view including
hierarchies from shared dimensions, if any. It also displays the measures defined in the calculation
view.
b. Drag and drop a hierarchy to the Selected Hierarchy pane.

 Restriction

The tool does not support preview of multiple hierarchies at the same time. You can preview output
in hierarchical tree structure of only one hierarchy at a time.

c. (Optional) If you want to preview the output with one or more measures from the calculation view, drag
and drop the measure to the Selected Measure(s) pane.
The tool constructs the output data in hierarchical tree structure for the selected configuration. The
root node is expanded and the number of records displayed depends on the MDX console or SQL
console settings.

SAP HANA Modeling Guide


Creating a Graphical Calculation View PUBLIC 95
 Note

MDX queries do not support history enabled parameters and does not obey any pruning settings
defined for the calculation view. Thus, they are not part of the hierarchy data preview.

d. If you are previewing output of a calculation view with data category as CUBE and if you want to view
the MDX query that the tool executed to fetch the output data, in the toolbar, choose MDX.
e. If you are previewing output of a calculation view with data category as Dimension and if you want to
view the SQL query that the tool executed on the BIMC tables to fetch the output data, in the toolbar,
choose SQL.

f. If you want to export the output data to a .csv file, in the toolbar, choose (Download).
10. Preview output of intermediate nodes.
If you have activated the calculation view, you can also preview the output of any of its intermediate view
nodes. This preview helps know the output data that is passed to the higher view node levels.
a. Switch to the Development perspective.
b. In the Workspace view, select the required calculation view and open it in the view editor.
c. Right-click the required intermediate view node and choose Data Preview.

Related Information

Create Graphical Calculation Views [page 10]

SAP HANA Modeling Guide


96 PUBLIC Creating a Graphical Calculation View
4 Working With Attributes and Measures

Attributes and measures form content data that you use for data modeling. Attributes represent the
descriptive data, such as product and region, and measures represent quantifiable data such as revenue and
quantity sold.

Columns in calculation views are either a measure or attribute. Measures are columns where you define an
aggregation. If calculation views are used in SQL statements, aggregate the measures. For example, using the
SQL functions SUM(<column name>), MIN(<column name>), or MAX(<column name>. Attributes can be
handled as regular columns because they don't need to be aggregated.

This section describes the various operations you can perform with attributes and measures. For example, you
can create calculated attributes or calculated measures.

Related Information

Create Counters [page 98]


Create Calculated Columns [page 99]
Assign Semantics [page 103]
Create Input Parameters [page 112]
Assign Variables [page 107]
Using Currency and Unit of Measure Conversions [page 129]
Enable or Disable Attributes for Drilldown in Reporting Tools [page 147]
Assign Value Help for Attributes
Create Restricted Columns [page 100]
Handle Null Values in Columns [page 147]
Convert Attribute Values to Required Formats [page 149]
Group Related Measures and Attributes [page 152]
Using Hierarchies for Reporting [page 119]
Associate Attributes with Other Related Attributes [page 151]
Assign Value Helps for Attributes [page 146]

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 97
4.1 Create Counters

Use counters to count the number of distinct values in one or more attribute columns. Counters are columns
that display the distinct count of attribute columns.

Context

You can create counters for multiple attribute columns at a time. For example, if you create a counter for two
columns, the counter displays the count of distinct combinations of both columns.

Procedure

1. Open the required calculation view in the view editor.


2. Select the default aggregation node or the star join node.

 Note

You can create counters for attribute columns in the default aggregation node or star join node only.

3. In the editor toolbar, choose (Expand Details Panel).

4. In the Calculated Columns tab, choose (Add) and select the Counter menu option.
5. Define the counter.
a. Select and expand the new counter.
b. In the General section, provide a name and description for the new counter.
c. If you want to hide the counter for data preview, select Hidden.
d. In the Counter section, choose + (Add).
e. In the value help list, choose an attribute column.

 Note

Transparent Filter Flag

Set the transparent filter flag on attribute columns to True to get correct counter results in the
following scenarios:
○ Calculation views are stacked on top of other dependent calculation views, and you have
defined count-distinct measures in the dependent views.
○ Queries on main calculation views let you filter column that you do not want to project.

For these scenarios, set the transparent filter flag to True on the filtered, nonprojected columns.
You must set the filter for these columns in all view nodes of the upper calculation view, and also in
the default node of the lower dependent calculation view. This flag helps correct unexpected
counter numbers.

SAP HANA Modeling Guide


98 PUBLIC Working With Attributes and Measures
4.2 Create Calculated Columns

Create calculated columns as new output columns for a view, and calculate the column values at runtime
based on the result of an expression. You can use other column values, functions, input parameters, or
constants in the expression.

Context

For example, you can create a calculated column DISCOUNT using the expression if ("PRODUCT" =
'NOTEBOOK', "DISCOUNT" * 0.10, "DISCOUNT"). In this sample expression, you use the function if(),
the column PRODUCT and operator * to obtain values for the calculated column DISCOUNT.

Procedure

1. Open the required calculation view in the view editor.


2. Select the view node in which you want to create the calculated column.

3. In the editor toolbar, choose (Expand Details Panel).


4. In the Calculated Columns tab, choose + (Add).
5. Select and expand the new calculated column.
6. In the General section, enter a name for the new calculated column.
7. In the Data Type dropdown list, select the data type for the calculated column.
8. Enter values for length and scale based on the selected data type.
The tool ignores the length for VARCHAR data type. If you want to, for example, truncate length, use the
relevant string functions in calculated column expression.
9. (Optional) Define the calculated column.

If you are creating calculated columns in the default view nodes of cubes (calculation views of type cube),
you can define the semantics for the calculated column. In this view node, you can create calculated
attributes or calculated measures using attributes or measures respectively.
a. Select the default view node.
In the Semantics section, provide semantics information for the new calculated column.
b. In the Column Type dropdown list, select a value.
c. If you want to create a calculated measure and enable client-side aggregation for the calculated
measure, select Enable client side aggregation and, in the Aggregation Type dropdown list, select an
aggregation type that the client must perform on calculated measures.

 Note

After selecting the Enable client side aggregation checkbox, in the Aggregation Type dropdown list,
select an aggregation type that client must perform on the calculated measures.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 99
d. Drilldown in the calculated attributes in the reporting tools.
By default, the tool lets you to drilldown calculated attributes in reporting tools. If you want to disable
the drilldown property, in the Drill Down dropdown list, set the value to blank.
e. If you want to hide the calculated column in reporting tools, select Hidden.
10. Provide an expression.

You can create an expression using the SQL language or the column engine language.
a. In the Expression section, choose Expression Editor.
b. In the Language dropdown list, select the language you want to use to create the expression.
c. In the expression editor, enter a valid expression.

The tool computes this expression at runtime to obtain values of calculated columns.

For example, if("PRODUCT" = 'NOTEBOOK', "DISCOUNT" * 0.10, "DISCOUNT"), which is


equivalent to, if attribute PRODUCT equals the string ‘NOTEBOOK’ then DISCOUNT equals to DISCOUNT
multiplied by 0.10 should be returned. Else use the original value of the attribute DISCOUNT.

 Note

You can drag and drop the expression elements, operators, and functions to the editor and create
expressions.

d. Choose Validate Syntax to identify any inconsistencies in the expression.


e. Choose Back.

4.3 Create Restricted Columns

Create restricted columns as an additional measure based on attribute restrictions. For example, you can
choose to restrict the values for the REVENUE column only to REGION = APJ, and YEAR = 2012.

Context

You can also use the capbilities of restricted measures to create a simple pivoting of your data.

For restricted columns, the tool uses the aggregation type of the base column. You can define restrictions on
measures using any of the following approaches:

● Define restrictions on measures using values from other attribute columns.


● Define restriction on measures using expressions based on SQL language or column engine language.

Procedure

1. Open the required graphical calculation view in the editor.

SAP HANA Modeling Guide


100 PUBLIC Working With Attributes and Measures
2. Select the required aggregation node.

 Note

You can create restricted columns in star join nodes or aggregation nodes only.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the Restricted Columns tab.
5. Choose + (Add).
6. Select and expand the new restricted column.
7. In the General section, provide a name and label for the new restricted column.
8. In the Base Measure dropdown list, choose a base measure value on which you want to apply restrictions.
9. If you want to hide the restricted column in reporting tools, select the Hidden checkbox.
10. Define restrictions.
You can define restrictions on the base measure using constant values, fixed values from other attribute
columns, or input parameters.
a. In the Restrictions section, select Columns.
b. Choose + (Add).
c. In the Column value help list, select an attribute column.
d. In the Operator dropdown list, select a required operation to define the condition.
If you are using BETWEEN operator, enclose strings that contain hyphen (-) character within double
quotes. Example, "HT-100".
e. In the Value field, use the value help to select a value type.
You can provide a fixed value from the attribute column or use an input parameter to provide value at
runtime. Provide or select the required value and choose OK.

 Note

The tool populates the value help list only if the calculation view in which you are defining the
restricted column is built at least once.

f. If you want to apply restrictions based only on the defined conditions, choose Include.

 Note

You can define multiple conditions using the same attribute columns or different attribute
columns. For example, the expression, ("CUSTOMER_ID" = '10' OR "CUSTOMER_ID" =
'2010') AND ("CUSTOMER_NAME" = '' ") has three conditions.

11. Apply restrictions using expressions.

If you do not want to use a column value, but instead create and use an expression using the SQL language
or the column engine language to define restrictions.

 Note

Only a limited lists of SQL functions are supported for expressions in SQL language.

a. In the Restrictions section, select Expression.


b. In the Language dropdown list, select an expression language.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 101
c. In the Expression Editor, enter a valid expression.

 Note

You can also use input parameters in your expressions to create restricted columns.

d. (Optional) Select Validate Syntax to validate the expression.

4.3.1 Example: Using Restricted Measures for Pivoting

You can also use the capabilities of restricted measures to create a simple pivoting of your data.

For example, if you have data like the below sample data:

Sample Data
Year Measure_1 Measure_2

2015 10.1 100

2015 12.3 99

...

...

2015 13.12 120

2016 9.8 130

...

2017 11.23 103

...

and for the above example, if you want to have a separate measure for each year as a column in a keyfigure
model.

2015_Measure1 2015_Measure_2 2016_Measure_1 2016_Measure_2 ...

SAP HANA Modeling Guide


102 PUBLIC Working With Attributes and Measures
then for each intended column, you can create this by using a restricted measure that is based on the measure
and filters on the respective year. For example, the definition of the restricted measure 2015_Measure_1 will be
as seen below:

4.4 Assign Semantics

Assigning semantics to measures or attributes in calculation views helps define output structure of views.
Assigning semantics help attach information on the type of attributes and measures in the calculation view.

Context

Client tools use semantic types to represent data in appropriate format. Assigning semantics to attributes or
measures at design time helps provide meaning to attributes and measures.

Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the Columns tab.
5. Select a measure or attribute.

6. Choose (Assign Semantics).


7. Choose the Assign Semantics menu option.
8. In the Semantic Type dropdown list, select the required semantic type.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 103
9. Choose OK.

Related Information

Extract and Copy Semantics From Underlying Data Sources [page 104]
Propagate Columns to Semantics [page 106]
Supported Semantic Types for Measures [page 106]
Supported Semantic Types for Attributes [page 107]

4.4.1 Extract and Copy Semantics From Underlying Data


Sources

Defining semantics for calculation views include defining the output columns, variables, or hierarchies of the
calculation views and their aggregation type. While defining the semantics for a calculation view, you can
extract and copy the semantic definitions of columns (or variables and hierarchies) from their underlying data
sources.

Context

For example, let's say you are modeling a complex calculation view with multiple underlying data sources, and
these data sources have their own semantic definitions for their columns. In this case, you can extract and copy
the semantic definitions of columns from their underlying data sources to define the semantics of the
calculation view. Extracting and copying the semantic definitions this way helps you save the effort of manually
defining the semantics of the calculation view.

Procedure

1. Open the required calculation view in view editor.


2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).

4. In the Columns tab, choose (Extract Semantics).

In the Extract Semantics dialog box, the tool displays the output columns from the underlying data
sources.
5. Select the columns.

By default, the column properties, Label, Label Column, Aggregation Type, and Semantic Type, is enabled.
This means that the values of these column properties are extracted from the underlying views to the

SAP HANA Modeling Guide


104 PUBLIC Working With Attributes and Measures
semantic definition of the calculation view. If you want to avoid copying the definition, in the Columns tab
you can clear the Aggregation Type checkbox.

 Note

If the same column is available in two or more data sources specify the data source that the tool must
use to extract and copy the semantic definition. In the Data Sources dropdown list, select the data
source.

6. (Optional) Select and extract the hierarchies.


If you want to extract and copy hierarchies defined in the underlying views to the semantic definition of the
target calculation view,
a. In the Extract Semantics dialog box, select the Hierarchies tab.

 Note

If the nodes in the hierarchies are also the output columns of the calculation view, you can extract
and copy hierarchies.

b. Select the hierarchies defined in the underlying views.


c. If the target calculation view already has hierarchies with same name, in the New Name field, provide a
different name.
7. (Optional) Select and extract the variables.
If you want to extract and copy variables defined in the underlying views to the semantic definition of the
target calculation view,
a. In the Extract Semantics dialog box, select the Variables tab.
b. Select the variables defined in the underlying views.
c. If the target calculation view already has variables with same name, in the New Name field, provide a
different name.

 Note

You can extract only those variables to the calculation view whose reference column or hierarchy (used
in the variable definition) are also part of the calculation view.

8. If you want to override the existing semantic definition of the calculation view with the extracted semantics,
select the Overwrite semantics already defined checkbox.
9. Choose OK.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 105
4.4.2 Propagate Columns to Semantics

Propagate columns from underlying view nodes to the semantics node and to other view nodes that are in the
joined path. In other words, you can reuse columns from underlying view nodes as output columns in all view
nodes and up to the semantic node.

Context

The tool lets you propagate columns from an underlying view node to all nodes in the joined path up to the
semantics node. This means that you don't have to define the output columns of each node, if the same
columns are already defined in its underlying node and you need these output columns in the above nodes up
to the semantic node. Propagating columns are useful in complex calculation views that many levels of view
nodes.

Procedure

1. Open the required calculation view in the view editor.


2. Select a view node.

 Note

You cannot select the default view node and propagate columns to the semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. In the Mapping tab, select an output column that you want to propagate to the semantics node.
5. In the context menu, choose Propagate to Semantics.

Results

The tool propagates the columns you select to all view nodes and up to the semantics node. If some columns
are already available in any of the view nodes in the propagated path, the tool does not propagate columns to
those nodes.

4.4.3 Supported Semantic Types for Measures

The following semantic types are supported for measures.

● Amount with Currency Code


● Quantity with Unit of Measures

SAP HANA Modeling Guide


106 PUBLIC Working With Attributes and Measures
4.4.4 Supported Semantic Types for Attributes

The following semantic types are supported for attributes.

● Amount with Currency Code


● Quantity with Unit of Measures
● Currency Code
● Unit of Measure
● Date
● Date – Business Date From
● Date – Business Date To
● Geo Location - Longitude
● Geo Location - Latitude
● Geo Location - Carto ID
● Geo Location – Normalized Name
● Hyperlinks - Attribute values as navigable hyperlinks

For associating attributes with Quantity with Unit of Measures or Amount with Currency Code, specify the unit
column and currency column respectively.

4.5 Assign Variables

Calculation views contain variables that are bound to specific attributes within the calculation view. Variables
are runtime filters that help to filter attributes, based on values that users provide.

Context

You assign variables to attributes in calculation views to, for example, filter the results. At runtime, you can
provide values to variables by manually entering a value or by selecting them from the value help list.

Procedure

1. Create a variable.
a. Select the Semantics node.

b. In the editor toolbar, choose (Expand Details Panel).


c. Choose the Parameters tab.

d. Choose (Add).
e. Choose the Variable menu option.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 107
f. Select and expand the new variable.
2. Define a variable type.
a. Provide a name and description for your variable.
b. In the Selection Type dropdown list, select a variable type.
c. If you want to configure the variable to mandatorily accept a value at runtime, select the Is Mandatory
checkbox.

 Note

If you do not provide a value to variable at runtime and if you have not selected the Is Mandatory
checkbox, then the tool displays unfiltered data.

d. If you want to configure the variables to accept multiple values from client tools at runtime, select the
Multiple Entries checkbox.

For example, you can assign variables to identify the revenue for the period 2000 to 2005 and 2012, at
runtime.
3. Define values for the value help list.
a. If you want to use attribute data from another calculation view as the reference column, use a View/
Table Value Help to select the calculation view that contains the required attribute.
b. In the Reference Column value help list, choose an attribute value.
The tool uses this attribute data to provide values in the value help list at runtime.
c. In reporting tools, if you want to use a hierarchy from the calculation view to organize the filtered data,
then in the Hierarchy dropdown list, select a hierarchy.
Selecting a hierarchy also helps populate values in the variable value help list at runtime with
hierarchical representations.

 Note

The hierarchy must contain the variable's reference column at the leaf level (in level hierarchies) or
as a child attribute (in parent-child hierarchies). In addition, hierarchical value helps are supported
only for variables of type Single.

4. Provide a default value.

Provide a default value that the tool must consider as the variable value when you do not provide any value
to the variable.
a. In the Default Value section, provide default values using constant values or expressions.

Default Value Meaning

Constant If you want to use a constant as the default variable value, do the following:
1. In the Type dropdown list, select Constant.
2. Provide values for From Value or both From Value and To Value depending on the variable
type and the operator.
For example, if you are using variable type Single Value and operator Equal, provide just
the From value.

SAP HANA Modeling Guide


108 PUBLIC Working With Attributes and Measures
Default Value Meaning

Expression If you want to provide the result of an expression as the default value, do the following:
1. In the Type dropdown list, select Expression.
You use the column engine language or the SQL language to provide the expression.
2. Provide values for From Value or both From Value and To Value depending on the variable
type and the operator.
For example, if you are using variable type Single Value and operator Equal, then provide
just the From value.
3. In the From Value field or To Value field, choose the value help icon to open the expres­
sion editor.
4. In the Expression Editor, provide a valid expression.
5. Choose Validate Syntax to identify any inconsistencies in the expression.
6. Choose Back.

 Note

Providing multiple default values.

If you have configured the variable to accept multiple values at the runtime by selecting the Multiple
Entries checkbox, then you can provide multiple default values to the variable. In the Default Value
section, choose + to add multiple default values. You can select these values from the selection screen
when executing the calculation view.

5. Assign variables to attributes.

Assign the variable to an attribute to filter its data at runtime.


a. In the Apply Filter section, choose + (Add) to add an attribute.
b. In the Attribute value help, select an attribute.

Related Information

Supported Variable Types [page 110]

4.5.1 Use Session Variables

The calculation view editor allows you to use predefined session variables or user-defined session variables in
filter expressions or calculated columns.

Prerequisites

You have set the user-defined session variable in the context, M_SESSION_CONTEXT. Use the SQL Script
statement SET to define the variable in the context. For example, SET SESSION
<'variable_name'>=<'value'>.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 109
 Note

You have to define the variable in the current session and is available for the current session only.

Context

The session variables provide information on the current context.

 Restriction

You cannot use session variables in restricted columns.

Procedure

1. Open the required calculation view in the view editor.


2. Double-click the view node in which you want to filter columns with session variables.

3. In the Parameters tab, choose .


4. Choose the Session Variable menu option.
5. Select and expand the new session variable.
6. Define the required session variable.
a. To use a predefined session variable, in the Session Variable dropdown list, select the required
predefined session variable.
b. If you want to use a custom session variable, in the Session Variable text field, enter the required
variable name.

Next Steps

After you have defined the session variable, in filter expressions or calculated columns, you can access and use
the session variable in the expression editor.

4.5.2 Supported Variable Types

Graphical calculation views support the following variable types for assigning variables to attributes.

Type Description

Single value Filter and view output data, based on a single attribute value. For example, to view the sales of a prod­
uct, where the month is equal to January.

SAP HANA Modeling Guide


110 PUBLIC Working With Attributes and Measures
Type Description

Interval Filter and view a specific set of output data. For example, to view the expenditure of a company from
March to April.

Range Filter view output data, based on the conditions that involve operators such as "="(equal to), ">"
(greater than), "<" (less than), ">=" (greater than or equal to), and "<=" (less than or equal to). For
example, to view the sales of all products in a month where the quantity sold is >= 100.

4.5.3 Supported Session Variables

The calculation view editor supports using predefined session variables to filter columns.

The table lists the session variable that you can use in filter expresssion or calculated columns.

Supported Predefined Session Variables


Variable Value Constraint Set by Description

APPLICATION NVARCHAR(256) User/Client Specifies the application


name.

APPLICATIONSTACK NVARCHAR(256) User/Client

APPLICATIONUSER NVARCHAR(256) User/Client Specifies the application-de­


fined user name.

APPLICATIONVERSION NVARCHAR(256) User/Client Specifies the application ver­


sion information.

Applications can use their


"own" version naming, no for­
mat is predefined

DRIVERVERSION Specifies the version number


of the driver being used to
connect

PROTOCOL_VERSION - Server Specifies the protocol ver­


sion of the client interface li­
braries, formatted as: <pro­
tocol_version> (<distribu­
tion_protocol_version>,
<data_format_version>).
For example, 4.1 (1,1) For ex­
ample, 4.1(1,1).

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 111
Variable Value Constraint Set by Description

XS_APPLICATIONUSER - server:XS client with security Writable XS_APPLICATIO­


token NUSER variable. The value
has to be a security token.
For example, saml-assertion.

The value is internally vali­


dated and the user name is
stored as variable value. The
X Sengine will still set the
user name directly.

The session variable XS_AP­


PLICATIONUSER are always
shown in M_SESSION_CON­
TEXT, defaulting to SQL user.

4.6 Create Input Parameters

Input parameters help you parameterize calculation views and execute them based on the values that users
provide to the input parameters at query runtime. The engine considers values provided for the input
parameters as the PLACEHOLDER clause of the SQL statement.

Context

You create an input parameter at design time (while modeling a calculation view), and provide values to the
input parameter placeholder at runtime to execute the calculation view. For example, if you want the
calculation view to provide data for a specific region, then REGION is a possible input parameter. Create the
input parameter, REGION and use it in a filter expression. At runtime, the data is filtered based on the value
provided to the input parameter, REGION.

Procedure

1. Open the required calculation view in the view editor.


2. Select a view node in which you want to create the input parameter.

 Note

Input parameters are not specific to the view nodes and are defined at the view level.

SAP HANA Modeling Guide


112 PUBLIC Working With Attributes and Measures
3. In the editor toolbar, choose (Expand Details Panel).
4. Choose the Parameters tab.

5. Choose (Add).
6. Select Input Parameter.
7. Maintain input parameter details
a. Select and expand the new input parameter.
b. In the General section, provide the input parameter name and description.
a. If you want to configure the input parameter to mandatorily accept a value at runtime, select the Is
Mandatory checkbox.
b. If you want to configure the input parameter to accept multiple values at runtime, select the Multiple
Entries checkbox.
For example, you can create input parameter to identify the revenue for the period 2000 to 2005 and
2012, at runtime.
8. Define input parameter type.
a. In the Parameter Type dropdown list, select an input parameter type.

Input Parameter
Type Description Next Steps

Direct Specify the data type and length and a. (Optional) In the Semantic Type dropdown
scale of the input parameter value that list, specify the semantic type for the input pa­
you want to use at runtime. rameter.

You can also define an input parameter b. In the Data Type dropdown list, select the data
with semantic type as Currency or Unit type.
of Measure or Date.
c. Provide the Length and Scale for the data type
For example, in currency conversions, you choose.
you can specify the target currency
value at runtime by creating an input pa­
rameter of type Direct with a semantic
type as Currency.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 113
Input Parameter
Type Description Next Steps

Column At runtime, the tool provides a value a. If you want to use attribute data from another
help list with attribute data. You can calculation view as the reference column, use a
choose a value from the attribute data View/Table for value help to select the calcula­
as an input parameter value. tion view that contains the required attribute.

If you have used the attribute data in a b. In the Reference Column value help list, select
hierarchy definition, then select the re­ an attribute.
quired hierarchy from the calculation
c. If you have used the reference column in a hi­
view to populate the values in input pa­
erarchy, and if you want to use a hierarchy from
rameter value help list at runtime with
the calculation view to organize the data in re­
hierarchical representations.
porting tools, in Hierarchy dropdown list, select
the required hierarchy.
 Note
The hierarchy must contain the ref­
erence column of the variable at the
leaf level (in level hierarchies) or as
a parent attribute (in parent-child
hierarchies).

Static List At runtime, the tool provides a value a. In the Data Type dropdown list, select the data
help list with the static list. You can type for the list values
choose a value from this list as an input
b. Provide the Length and Scale for the data type
parameter value.
you choose.

c. In the List of Values section, choose + (Add) to


provide the list values.

SAP HANA Modeling Guide


114 PUBLIC Working With Attributes and Measures
Input Parameter
Type Description Next Steps

Derived From Table At runtime, the tool uses the value from a. Use the Table Name to select a table.
the reference column of the table as the
b. For the table you selected, in the Reference
input parameter value. This means that
Column dropdown list, select a column value.
it is not necessary to provide any values
to the input parameter at runtime. c. In the Filters section, define filter conditions to
filter the values of the return column.
Input parameters of this type are typi­
cally used to evaluate a formula. For ex­ d. If you want to provide a different value to the
ample, you calculate a discount for spe­ parameter at runtime (overriding the default
cific clients by creating an input param­ value) and do not want the tool to automatically
eter, which is derived from the SALES use the value returned by the table as the input
table and reference column REVENUE parameter, select Input Enabled checkbox.

with a filter set on the CLIENT_ID.


 Note
You can configure input parameters of type,
Derived from table to mandatorily accept a
value at runtime only if it is input enabled.

If this checkbox is enabled, at runtime the tool


displays the value returned by the table as the
default value, but you can override this value
based on your requirements.

Derived From Proce­ At runtime, the tool uses the value re­ a. In the Procedure/Scalar Function field, provide
dure/Scalar Function turned from the procedure or scalar as the name of procedure or scalar function.
the input parameter value.
b. If you want to provide a different value to the
parameter at runtime (override the default
value) and don't want the tool to automatically
use the value returned by the procedure, select
Input Enabled checkbox.

 Note
You can configure input parameters of type,
Derived from Procedure/Scalar Function to
mandatorily accept a value or multiple val­
ues at runtime only if it is input enabled.

If this checkbox is enabled, then at runtime the


tool displays the value returned by the proce­
dure or scalar function as the default value, but
you can override this value based on your re­
quirements.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 115
 Note

You cannot configure input parameters of type, Derived from table to accept multiple values at
runtime.

9. Provide default values.


Provide a default value that the tool must consider as the input parameter value if no value is provided to
the input parameter at runtime.
a. In the Default Value(s) section, provide default values using constant values or expressions.

 Note

The tool cannot accept a combination of expressions and constants as default values for input
parameters.

Default Value Meaning

Constant If you want to use a constant value as the default input parameter value,
1. In the Default Value(s) section, choose + (Add).
2. In Type dropdown list, select Constant.
3. In Value value help list, provide a constant value.

Expression You can create an expression in SQL language or the column engine language. If you want to
use the result of an expression as the default input parameter value:

1. In the Default Value(s) section, choose the add icon.


2. In Type dropdown list, select Expression.
3. In the Value value help list, choose the value help to open the expression editor.
4. In the Expression Editor, enter a valid expression.
5. Choose Validate Syntax to identify any inconsistencies in the expression.
6. Choose Back.

For example, you can evaluate the expression date(Now()), and use the result as the de­
fault input parameter value at runtime.

 Note

Providing multiple default constant values. If you have configured the input parameter to accept
multiple values at the runtime by selecting the Multiple Entries checkbox, then you can provide
multiple default constant values to the input parameter. In the Default Value(s) section, choose + to
add multiple default constant values. These values appear on the selection screen when you run
the calculation view.

Related Information

Map Input Parameters [page 117]


Input Parameters [page 118]

SAP HANA Modeling Guide


116 PUBLIC Working With Attributes and Measures
4.6.1 Map Input Parameters

If you are modeling calculation views on top of other calculation views that have input parameters defined for
them, you can map the input parameters of underlying data sources to the input parameters of calculation
views that you are modeling.

Context

When you map parameters of the current view to the parameters of the underlying data sources, the filters are
moved down to the underlying data sources at runtime. This reduces the amount of data transferred across
them.

 Note

Input parameters are available for mapping only when used in the dependent data sources.

Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the Parameters tab.

5. Choose (Manage Parameter Mapping).


6. In the Type dropdown list, select the required value.

Value Description

Data Sources If you are using other calculation views as data sources in a calculation view, and if
you want to map input parameters of the underlying data sources to the input
parameters of the calculation view.

Procedures/Scalar functions If you are using input parameters of type procedure/scalar functions, and if you want
for input parameters to map the input parameters defined in the procedures or scalar functions to the
input parameters of the calculation view.

Views for value help for If you are using input parameters or variables that refer to external views for value
variables/input parameters help references, and if you want to map input parameters of external views to the
input parameters of the calculation view.

Views for value help for If you are filtering the attributes in the underlying data sources using other
attributes calculation views or tables as value help, and if you want to map the input parameters
in these value help views to the input parameters of the calculation view.

7. Manage mappings for the source and target input parameters by dragging a value from the source to a
value in the target.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 117
8. If you want to auto-map, based on the source and target input parameter names,

a. On the toolbar, choose (Auto Map by Name).

 Note

If you are using auto-map, to map all unmapped parameters at the source, the system creates
input parameters with same name at the target.

9. If you want to create a constant value at the target calculation view,

a. Select (Create Constant).


b. Enter a constant value.
c. Choose OK.

Related Information

Create Input Parameters [page 112]


Input Parameters [page 118]

4.6.2 Input Parameters

Use input parameters to parameterize the view and to obtain the desired output when you run the view.

This means that the engine uses the parameter value that users provide at runtime, for example, to evaluate
the expression defined for a calculated measure. The parameter value is passed to the engine through the
PLACEHOLDER clause of the SQL statement. A parameter can only have a single value, for example, for
currency conversion. However, when working with the in() function in filter expressions of calculation views,
you can pass several values as an IN List. When defining the expression, quote the expression as described
here:

For numerical type parameters

The filter expression of a calculation view CV1 is defined as follows:

in("attr", $$param$$)

Then pass several values as:

select ... from CV1( 'PLACEHOLDER' = ('$$var$$' = 'VAL1, VAL2, VAL3')

For string type parameters

The filter expression of a calculation view CV1 is defined as:

in("attr", $$param$$)

Then pass several values (with double quotes) as:

select ... from CV1( 'PLACEHOLDER' = ('$$var$$' = '''VAL1'',''VAL2'',''VAL3''')

SAP HANA Modeling Guide


118 PUBLIC Working With Attributes and Measures
The table here summarizes with some examples the input parameter expressions at design time and the query
at runtime.

Input Parameter
Data Type Multiple Values Expression In Query

Integer False in("ID",$$IP_1$$) (placeholder."$$IP_1$$"=>1)

Varchar False in ("elem_2",'$$IP_1$ (placeholder."$$IP_1$


$') $"=>'test')

Varchar False "elem_2" = '$$IP_1$$' (placeholder."$$IP_1$


$"=>'test')

Integer True in("elem_3",$$IP_1$$) (placeholder."$$IP_1$


$"=>'2,3')

Varchar True in("elem_2",$$IP_1$$) (placeholder."$$IP_1$


$"=>'''test''')

Or

(placeholder."$$IP_1$
$"=>'''test'',''test2''')

You use input parameters as placeholders, for example, during currency conversion, unit of measure
conversion, or in calculated column expressions. When used in formulas, the calculation of the formula is
based on the input that you provide at runtime during data preview.

The expected behavior of the input parameter when a value at runtime is not provided is as follows:

Default Value Expected Behavior

Yes Calculates the formula based on the default value

No Results in error

The table implies that it is mandatory to provide a value for the input parameter at runtime, or assign a default
value while creating the view, to avoid errors.

4.7 Using Hierarchies for Reporting

The graphical calculation view editor in SAP Web IDE supports creating hierarchies using graphical modeling
tools. Hierarchies help organize data in a tree structure for multidimensional reporting.

Each hierarchy comprises of a set of levels having many-to-one relationships between each other and
collectively these levels make up the hierarchical structure. For example, a time-related hierarchy comprises of

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 119
levels such as Fiscal Year, Fiscal Quarter, Fiscal Month, and more. You can graphically create the following two
types of hierarchies:

● Level Hierarchies
● Parent-Child Hierarchies

Related Information

Create Level Hierarchies [page 120]


Create Parent-Child Hierarchies [page 123]
Root Node Visibility [page 129]
Orphan Nodes [page 128]

4.7.1 Create Level Hierarchies

In level hierarchies, each level represents a position in the hierarchy. For example, a time dimension can have a
hierarchy that represents data at the month, quarter, and year levels.

Context

Level hierarchies consist of one or more levels of aggregation. Attributes roll up to the next higher level in a
many-to-one relationship and members at this higher level roll up into the next higher level, and more, until
they reach the highest level. A hierarchy typically comprises of several levels, and you can include a single level
in more than one hierarchy. A level hierarchy is rigid in nature, and you can access the root and child node in a
defined order only.

Procedure

1. Start SAP Web IDE in a Web browser.


2. Open the required calculation view in the view editor.
3. Select the Semantics node.

4. In the editor toolbar, choose (Expand Details Panel).


5. Choose the Hierarchies tab.

6. Choose (Add).
7. Choose the Level Hierarchy menu option.
8. Provide hierarchy details
a. Select and expand the new level hierarchy.

SAP HANA Modeling Guide


120 PUBLIC Working With Attributes and Measures
b. In the General section, provide a name and label to the new hierarchy.
9. Define node style

The node style determines the node ID for the level hierarchy.

a. In the Node Style dropdown list, select a value.


10. Create levels.
a. In the Nodes tab, choose + (Add) to create a level.
b. In the Column value help list, select the required column value for each level.
c. In Level Type dropdown list, select a required level type.

The level type specifies the semantics for the level attributes. For example, level type TIMEMONTHS
indicates that the attributes are months such as, "January", February, and similarly level type
REGULAR indicates that the level does not require any special formatting.
d. In the Order BY value help list, select a column value that the tool must use to order the hierarchy
members.

 Note

MDX client tools use attribute values to sort hierarchy members.

e. In the Sort Direction dropdown list, select a value that the tool must use to sort and display the
hierarchy members.
11. Define level hierarchy properties.

For supporting different business scenarios, the tool allows you to define certain additional properties for
the hierarchy. In the Properties section, define the required values.

a. Select the Aggregate All Nodes checkbox to include the values of intermediate nodes of the hierarchy
to the total value of the root node of the hierarchy. If you do not select the Aggregate All Nodes
checkbox, the tool does not roll-up the values of intermediate nodes to the root node.

 Note

The value of Aggregate All Nodes property is interpreted only by the SAP HANA MDX engine. In the
BW OLAP engine, the tool always counts the node values. Whether you want to select this property
depends on the business requirement. If you are sure that there is no data posted on aggregate
nodes, do not select the checkbox. This helps the engine to execute the hierarchy more efficiently.

b. If you want to cache the hierarchy data after executing a query on the hierarchy, select the Cache
checkbox.
c. If you want to convert the empty string values to NULL in client tools, select the Convert empty string
values to NULL checkbox.

The empty values are replaced with NULL in reporting tools.


d. In the Default Member text field, enter a value for the default member.

This value helps the tool identify the default member of the hierarchy. If you do not provide any value,
all members of hierarchy are default members.
e. In the Root Node Visibility dropdown list, select a value.

This value helps the tool identify whether it is necessary to add an additional root node to the
hierarchy.
f. In the Orphan Nodes dropdown list, select a value.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 121
This value helps the tool identify how to handle orphan nodes in the hierarchy.

 Note

If you select Step Parent option to handle orphan nodes, in the Step Parent text field, enter a value
(node ID) for the step parent node. The step parent node must already exist in the hierarchy at the
root level and enter the node ID according to the node style that you select for the hierarchy. For
example if you select node style Level Name, the step parent node ID can be [Level2].[B2]. The tool
assigns all orphan nodes under this node.

12. (Optional) Handle values in fact table, which do not have corresponding values in master table.
In calculation views of type dimensions or shared dimensions (dimensions in star join calculation views),
you can create a new Not Assigned Member in the level hierarchy and use this hierarchy member to
captures all values in fact table, which do not have corresponding values in the master table. In level
hierarchies, the not assigned member appears at each level of the hierarchy.
a. Expand the NULL HANDLING section.
b. If you want to capture values in the fact tables that do not have corresponding values in the master
table, then in the Not Assigned Members dropdown list, select Enable.
By default, the tool does not provide a hierarchy member to capture such values. This means that, Not
Assigned Members is disabled. You can either enable or choose Auto Assign to handle unassigned
members.

 Note

Selecting Auto Assign to handle not assigned members impacts the performance of your
calculation view. Select Auto Assign with caution.

c. Provide a name and label to the hierarchy member.


This label value appears in reporting tools or client tool along with the unassigned members.
d. If you want to drilldown this member in reporting tool, select the Enable Drilldown checkbox.
e. If you want to use null convert values to process NULL values in the fact table, which do not have any
corresponding records in the master table, select the Null Value Processing checkbox.
By default, the tool uses the string, _#_ as the null convert value. You can change this value in the
Name field under the Null Value Member Properties section.
f. Provide a label for the null value member.
This value appears in the reporting tools to capture null values.

Related Information

Node Style [page 123]


Query Shared Hierarchies [page 127]
Orphan Nodes [page 128]
Root Node Visibility [page 129]

SAP HANA Modeling Guide


122 PUBLIC Working With Attributes and Measures
4.7.1.1 Node Style

Node style value defined for a level hierarchy helps the tool identify the format of the node ID in reporting tools.
For example, whether the node ID must comprise of the level name or node name or both in the reporting tools.

Node Style Description

Level Name For this node style, the node ID comprises of the level name and the node name.
For example, for a fiscal hierarchy, the Level Name node style implies: MONTH.JAN

Name Only For this node style, the node ID comprises of the level name only. For example, for
a fiscal hierarchy, the Name Only node style implies: JAN

Name Path For this node style, the node ID comprises of the node name and the names of all
ancestors apart from the (single physical) root node. For example, for a fiscal hier­
archy, the Level Name node style implies: FISCAL_2015.QUARTER_1.JAN

4.7.2 Create Parent-Child Hierarchies

In parent-child hierarchies, you use a parent attribute that determines the relationship among the view
attributes. Parent-child hierarchies have elements of the same type and do not contain named levels.

Context

Parent-child hierarchies are value-based hierarchies, and you create a parent-child hierarchy from a single
parent attribute. You can also define multiple parent-child pairs to support the compound node IDs. For
example, you can create a compound parent-child hierarchy that uniquely identifies cost centers with the
following two parent-child pairs:

● CostCenter and ParentCostCenter and


● ControllingArea and ParentControllingArea,

A parent-child hierarchy is always based on two table columns and these columns define the hierarchical
relationships among its elements. Others examples of parent-child hierarchies are bill of materials hierarchy
(parent and child) or employee master (employee and manager) hierarchy.

Procedure

1. Start SAP Web IDE in a Web browser.


2. Open the required calculation view in the view editor.
3. Select the Semantics node.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 123
4. In the editor toolbar, choose (Expand Details Panel).
5. Choose the Hierarchies tab.

6. Choose (Add).
7. Choose the Parent Child Hierarchy menu option.
8. Provide hierarchy details
a. Select and expand the new parent-child hierarchy.
b. In the General section, provide a name and label to the new hierarchy.
9. Create parent-child elements
a. In the Nodes tab, choose + (Add).
b. In the Child value help list, select the required column value as the child attribute.
c. In the Parent value help list, select the required column value as a parent attribute of the child column
that you have selected.
d. If you want to place orphan nodes in the hierarchy under a step parent node, then in the Step Parent
text field, enter a value (node ID) for the step parent node.
e. If you want to place the parent-child hierarchies under a root node, select the Root Node value help.

You can provide the Root Node value either as a fixed value or as an input parameter. In the Type
dropdown list, select the required input parameter, or select Fixed and provide the required threshold
value. Choose OK.

 Note

If you have selected root node visibility value as Add Root node, it is mandatory to provide the root
node value.

10. Define parent-child hierarchy properties.

For supporting different business scenarios, the tool allows you to define certain additional properties for
the hierarchy. In the Properties section, define the required values.

a. Select the Aggregate All Nodes checkbox to include the values of intermediate nodes of the hierarchy
to the total value of the root node of the hierarchy. If you do not select the Aggregate All Nodes
checkbox, the tool does not roll-up the values of intermediate nodes to the root node.

 Note

The value of Aggregate All Nodes property is interpreted only by the SAP HANA MDX engine. In the
BW OLAP engine, the tool always counts the node values. Whether you want to select this property
depends on the business requirement. If you are sure that there is no data posted on aggregate
nodes, do not select the checkbox. This helps the engine to execute the hierarchy more efficiently.

b. If you want the parent-child hierarchy to support multiple parents for its elements, select the Multiple
Parent checkbox.
c. If you want to cache the hierarchy data after executing a query on the hierarchy, select the Cache
checkbox.
d. If you want to convert the empty string values in the fact table that do not have corresponding values in
the master table to NULL, select the Convert empty string values to NULL checkbox.

The empty values are replaced with NULL in reporting tools.


e. In the Default Member textbox, enter a value for the default member.

SAP HANA Modeling Guide


124 PUBLIC Working With Attributes and Measures
This value helps the tool identify the default member of the hierarchy. If you do not provide any value,
all members of hierarchy are default members.
f. In the Root Node Visibility dropdown list, select a value.

This value helps the tool identify whether to add an additional root node to the hierarchy.
g. In the Orphan Nodes dropdown list, select a value.

This value helps the tool identify how to handle orphan nodes in the hierarchy.

 Note

If you select Step Parent option to handle orphan nodes, then in the Nodes section, enter a value
(node ID) for Step Parent. The step parent node must already exist in the hierarchy at the root level.

h. In the Cycles dropdown list, select the required cycle.

If the parent-child relationships in the hierarchy have a circular reference, then a parent-child hierarchy
is said to contain cycles. You can use any of the following options to handle the behavior of such
hierarchies at load time.

Options Description

Break up at load time The nodes are traversed until a cycle is encountered. The cycles are broken-up at
load time.

Traverse completely, then The nodes in the parent-child hierarchy are traversed once completely and then
breakup the cycles broken up.

Error Displays error when a cycle is encountered.

11. If you want to add additional attributes to the hierarchy view definition and use them to execute the
hierarchy, then
a. In the Additional Attributes section, choose + (Add).
b. In the Attributes value help list, select the required attribute value.
12. Order and sort hierarchy elements.

If you want to order and sort elements of a parent child hierarchy based on a column value,
a. In the Order By section, choose + (Add).
b. In the Order By value help list, select the required column value that the tool must use to order
hierarchy members.
c. In Sort Direction dropdown list, select the required value that the tool must use to sort and display the
hierarchy members.

 Note

MDX client tools use attribute values to sort hierarchy members.

13. Enable hierarchy for time dependency

In some business cases, the elements in a hierarchy are changing elements (time dependent elements). In
such cases, you can enable the parent-child hierarchy as a time dependent hierarchy. This helps to create
hierarchies that are relevant for specific time periods and to display different versions on the hierarchy at
runtime.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 125
 Note

Not all reporting tools support time dependent hierarchies. For example, time dependent hierarchies
does not work with BI clients such as MDX or Design Studio.

a. In the Time Dependency section, select the Enable Time Dependency checkbox.
b. In the Valid From Column value help list, select the required column value.
c. In the Valid To Column value help list, select the required column value.

The tool uses the Valid From Column and Valid To Column values as the required validity time for time
dependent hierarchies.
14. If you want to use an input parameter to specify the validity of the time dependent hierarchy at runtime,
a. Select Interval.
b. In the From Date Parameter dropdown list, select an input parameter that you want to use to provide
the valid from date at runtime.
c. In the To Date Parameter dropdown list, select an input parameter that you want to use to provide the
valid to date at runtime.
15. If you want to use an input parameter to specify the key date at runtime,
a. Select Key Date.
b. In the Key Date Parameter dropdown list, select an input parameter value that you want to use to
provide key date value at runtime.
16. (Optional) Handle values in fact table, which do not have corresponding values in master table.
In calculation views of type dimensions or shared dimensions (dimensions in star join calculation views),
you can create a new Not Assigned Member in the parent-child hierarchy and use this hierarchy member to
captures all values in fact table, which do not have corresponding values in the master table.
a. Expand the NULL HANDLING section.
b. If you want to capture values in the fact tables that do not have corresponding values in the master
table, then in the Not Assigned Members dropdown list, select Enable.
By default, the tool does not provide a hierarchy member to capture such values. This means that, Not
Assigned Members is disabled. You can either enable or choose Auto Assign to handle unassigned
members.

 Note

Selecting Auto Assign to handle not assigned members impacts the performance of your
calculation view. Select Auto Assign with caution.

c. Provide a name and label to the hierarchy member.


This label value appears in reporting tools or client tool along with the unassigned members.
d. If you want to drilldown this member in reporting tool, select the Enable Drilldown checkbox.
e. If you want to use null convert values to process NULL values in the fact table, which do not have any
corresponding records in the master table, select the Null Value Processing checkbox.
By default, the tool uses the string, _#_ as the null convert value. You can change this value in the
Name field under the Null Value Member Properties section.
f. Provide a label for the null value member.
This value appears in the reporting tools to capture null values.

SAP HANA Modeling Guide


126 PUBLIC Working With Attributes and Measures
Related Information

Query Shared Hierarchies [page 127]


Orphan Nodes [page 128]
Root Node Visibility [page 129]

4.7.3 Query Shared Hierarchies

Enable SQL access to shared hierarchies and query them using SQL statements at runtime. This is necessary
to obtain correct aggregation results for hierarchy nodes.

Context

Calculation views in star join nodes are referred to as shared dimensions. The tool includes all attributes and
hierarchies of a shared dimension to the output of the star join calculation view. You can enable SQL access to
shared hierarchies and query them at runtime.

 Note

Not all reporting tools support SQL access to shared hierarchies. For example, this feature does not work
with BI clients such as MDX or Design Studio.

Procedure

1. Open the required star join calculation view.


2. Select the Semantics node.
3. If you want to enable SQL access to only a selected list of shared hierarchies, then:

a. In the editor toolbar, choose (Expand Details Panel).


b. Choose the Hierarchies tab.
c. In the Shared section, select a hierarchy to which you want to enable SQL access.
d. Expand the SQL Access section
e. Select the Enable SQL access checkbox.
4. If you want to enable SQL access to all shared hierarchies of the current version of the calculation view,
then:
a. Select the View Properties tab.
b. In the General section, select the Enable Hierarchies for SQL access checkbox.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 127
Results

After you enable SQL access to shared hierarchies, the tool generates a Node column and a Hierarchy
Expression Parameter for the shared hierarchy with certain default names. You can use the node column to
filter and perform SQL GROUP BY operation and use the hierarchy expression parameter to filter the hierarchy
nodes (for example, if you want query only the children nodes of a parent-child hierarchy).

 Caution

Hierarchy Expression Parameter has been deprecated. We recommend you to not use this parameter in
your calculation view.

For example, the following query shows uses the node column to filter and perform SQL GROUP BY operation:

 Sample Code

select "HierarchyNodeColumn",
sum("Revenue") as "Revenue"
FROM "_SYS_BIC"."mini/CvSalesCubeHier" group by "HierarchyNodeColumn";

4.7.4 Orphan Nodes

The tool provides different options to handle orphan nodes in hierarchies. For example, you can specify
whether the orphan nodes are treated as error or root nodes or more.

Options Description

Root Node Treat orphan nodes as root nodes.

Error Stop processing the hierarchy and show an error.

Ignore Ignore orphan nodes.

Step Parent Put orphan nodes under a step parent node.

SAP HANA Modeling Guide


128 PUBLIC Working With Attributes and Measures
4.7.5 Root Node Visibility

Based on your business requirement, choose to add an additional root node to the hierarchy and place all other
nodes as its descendants.

Root Node Visibility Description

Add Root Node If Defined This is applicable only for parent-child hierarchies. The tool adds a
root node only if you have defined a root node value.

Add Root node The tool adds an additional root node to the hierarchy and all other
nodes are placed as descendants to this node. Select this value if
your hierarchy does not have a root node, but requires a root node for
reporting purposes. The tool creates a root node with the technical
name ALL.

Do Not Add Root Node The tool does not add any additional root node to the hierarchy.

4.8 Using Currency and Unit of Measure Conversions

If measures in calculation views represent currency or unit values, associate them with currency codes or unit
of measures respectively in the calculation view.

Associating measures help display the measure values along with currency codes or unit of measures at data
preview or in reporting tools. Associating measures with currency code or unit of measure is also necessary for
currency conversion or unit conversions.

The tool performs currency conversions based on the source currency value, target currency value, exchange
rate, and date of conversion. It also performs unit conversions based on the source unit and target unit. In
addition, you can also perform banking currency conversion based on the market data area, conversion type,
and the system time.

You can also use input parameters in currency conversion or unit of measure conversion to provide values at
runtime. For example, you can provide the target currency value or the target unit value at runtime.

Related Information

Associate Measures with Currency [page 130]


Associate Measures with Unit of Measure [page 138]
Reuse a Currency Conversion or Unit Conversion Definition [page 141]
Tag Measures as Converted or Unconverted Values [page 142]

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 129
4.8.1 Associate Measures with Currency

If measures in calculation views represent currency values, associate the measures with a currency code. This
helps to display the measure values along with the currency code at data preview or in reporting tools.

Prerequisites

The SAP HANA Database Module that contains the calculation view in which you are performing currency
conversions also has all tables necessary for currency conversions or has synonyms that refer to the currency
conversion tables.

● For ERP currency conversions, you have the standard SAP currency tables or synonyms of the tables,
TCURC, TCURF, TCURN, TCURR, TCURT, TCURV, TCURW, and TCURX.
● For banking currency conversions, you have the tables or synonyms of the tables, F4_FXRATES,
TF4_FXCVFCT, TF4_FXRTTYP, TCURX and TCURN.

 Caution

If you are not using synonyms, the structure of the tables (table definition) in the SAP HANA Database
Module that you are using for currency conversions must be similar to the standard currency tables listed
in the prerequisites.

Context

Associating measures with currency codes is also necessary for currency conversions. For example, let's say
you want to generate a sales report for a region in a particular currency code, but you have the sales data in the
database table with a different currency code. In this case, create a calculation view by using the table column
containing the sales data in the different currency as a measure, and associate the measure with your desired
currency to perform the currency conversion. Activate the calculation view to generate the reports you need.

Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

 Note

You can also assign associate measures in any of the Aggregation nodes with currency code values and
perform currency conversion.

3. In the editor toolbar, choose (Expand Details Panel).


4. In the Columns tab, select a measure to associate it with currency code.

SAP HANA Modeling Guide


130 PUBLIC Working With Attributes and Measures
5. In the menu bar, choose (Assign Semantics).
6. Choose the Assign Semantics menu option.
7. In the Semantic Type dropdown list, select Amount with Currency Code.
8. In the Application Type dropdown list, select a value.

Application Type Description

ERP To use R/3 ERP currency conversion functions as configured in the tables TCURR, TCURF,
TCURX, TCURN and TCURV.

Banking To use the banking currency conversion functions as configured in the tables F4_FXRATES,
TF4_FXCVFCT, TF4_FXRTTYP, TCURX and TCURN.

9. (Optional) Reuse currency conversion definition.


You can reuse the currency code values and currency conversion definition from a selected measure.
a. In the Reuse Semantics dropdown list, select the required measure.
The tool reuses the conversion semantics of the selected measure.
b. Select a reuse type.

Reuse Type Description

Reference Select to reuse conversion semantics of the selected measure as a reference in the currency
conversion definition of the target measure. In this reuse type, when you modify the conver­
sion semantics of the reference measure, the conversion semantics of the target measure
automatically points to the updated conversion semantics.

Copy Select to reuse by copying the conversion semantics of the selected measure to the conver­
sion definition of the target measure. In this reuse type, modifying the conversion semantics
of the selected measure does not modify the conversion semantics of the target measure.

The tool populates the Assign Semantics dialog box with currency code values and currency conversion
definition associated with the selected measure.

10. Select a display currency code value.

The tool displays the measure values with this currency code in reporting tools.
a. In the Display Currency dropdown list, select a value.

Value Description

Fixed Associate the measure with a currency code available in the currency table. This table ei­
ther is a synonym to the SAP currency table, TCURC, or has a structure similar to the
standard SAP currency table, TCURC.

Column Associate the measure with an attribute column available in the calculation view.

b. In the value help list, select the required value based on the selected display currency type.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 131
For Fixed display currency type, if you have TCURC and TCURT tables (or its synonyms) in the same
SAP HANA Database Module, you can view the currency code values in the value help list along with its
description.

 Note

The tool populates the value help list only if:


○ You have the TCURC table or its synonym in the same SAP HANA Database Module or
○ You have defined a TCURR table as the Rates table in the Conversion Table section
If the value help list is not populated, you can manually enter the required display currency code.

c. Choose OK.

11. Enable decimal shift.

By default, the precision of all values is two digits in SAP ERP tables. Because some currencies require
accuracy in value, the tool shifts the decimal points according to the settings in the TCURX currency table.
For example, if the source currency has 0 valid digits, it is necessary to multiply each value by 100 because
in SAP ERP systems values are stored using two digits.
a. If you want to enable a decimal shift for the selected display currency, select the Decimal Shifts
checkbox.
12. Enable conversion.
a. If you want to convert the measure value to another currency, select the Conversion checkbox.
13. Enable rounding.
If you have enabled conversion, and you want to round the result value after currency conversion to the
number of digits of the target currency, do the following:
a. Select the Rounding checkbox.

 Note

Use rounding cautiously because rounding errors could accumulate after subsequent aggregations.

14. Enable decimal shift back.

Decimal shift back is necessary if the result of the calculation views is interpreted in ABAP. The ABAP layer,
by default, always executes the decimal shift. In such cases, decimal shift back helps avoid wrong numbers
caused by a double shift.
a. If you want to shift back the result of a currency conversion according to the decimal places that you
use for the target currency, select Shift back.
15. Enable reverse lookup.
If you have enabled conversion, you can use reverse lookup method for currency conversion. This method
determines the conversion rates with swapped units and inverts the rate before conversion. For example, if
a user wants to convert EUR to USD but TCURR only has an entry for USD to EUR, then reverse lookup
method will find a rate (USD to EUR), invert it and finally convert EUR to USD.
a. If you wan to use the reverse lookup method in currency conversion, select Reverse Look Up.
16. Specify the conversion tables.
Specify the conversion tables that the tool must refer to for currency conversion

SAP HANA Modeling Guide


132 PUBLIC Working With Attributes and Measures
Table Application Type Table Description

ERP In the value help list, select a table that provides the exchange rate information
or the conversion rates.

This table either is a synonym to the SAP currency table, TCURR, or has a struc­
ture similar to standard SAP currency table, TCURR.
Rates
Banking In the value help list, select a table that provides the exchange rate information
or the conversion rates.

This table either is a synonym to the SAP table, F4_FXRATES, or has a structure
similar to standard SAP table, F4_FXRATES.

ERP In the value help list, select a table that provides the exchange rate types.

This table either is a synonym to the SAP currency table, TCURV, or has a struc­
ture similar to standard SAP currency table, TCURV.
Configuration
Banking In the value help list, select a table that provides the exchange rate types.

This table either is a synonym to the SAP table, TF4_FXRTTYP, or has a struc­
ture similar to standard SAP table, TF4_FXRTTYP.

ERP In the value help list, select a table that provides the conversion factors informa­
tion.

This table either is a synonym to the SAP currency table, TCURF, or has a struc­
ture similar to standard SAP currency table, TCURF
Prefactors
Banking In the value help list, select a table that provides the conversion factors informa­
tion.

This table either is a synonym to the SAP table, TF4_FXCVFCT, or has a struc­
ture similar to standard SAP table, TF4_FXCVFCT.

ERP In the value help list, select a table that provides the quotations information.

This table either is a synonym to the SAP currency table, TCURN, or has a struc­
ture similar to standard SAP currency table, TCURN.
Notations
Banking In the value help list, select a table that provides the quotations information
(price or amount quoted).

This table either is a synonym to the SAP currency table, TCURN, or has a struc­
ture similar to standard SAP currency table, TCURN.

ERP In the value help list, select a table that provides information on decimal places
in currencies.
Precisions
This table either is a synonym to the SAP currency table, TCURX, or has a struc­
ture similar to standard SAP currency table, TCURX.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 133
Table Application Type Table Description

Banking In the value help list, select a table that provides information on decimal places
in currencies.

This table either is a synonym to the SAP currency table, TCURX, or has a struc­
ture similar to standard SAP currency table, TCURX.

17. Provide additional details for currency conversions.


a. Choose the Definition tab.
b. In the Client dropdown list, select the required value that the tool must use for currency conversion
rates.

Value Description

Fixed Set a fixed client value or select a session client for currency conversions. Provide the re­
quired value in the value help list.

Column Attribute column available in the calculation view to provide the client value. Select the re­
quired value from the value help list.

Input Parameter Set an input parameter to provide the client value at runtime. Select the required input pa­
rameter from the value help list.

c. Specify the source currency.

In the Source Currency dropdown list, select the required value.

Value Description

Fixed Select the source currency value from the currency table. Provide the required value in the
value help list.

Column Attribute column available in the calculation view to provide the source currency value. Se­
lect the required value from the value help list.

For Fixed source currency type, if you have TCURC and TCURT tables (or its synonyms) in the same
SAP HANA Database Module, you can view the currency code values in the value help list along with its
description.

 Note

The tool populates the value help list only if:


○ You have the TCURC table or its synonym in the same SAP HANA Database Module or
○ You have defined a TCURR table as the Rates table in the Conversion Table section
If the value help list is not populated, you can manually enter the required display currency code.

d. Specify the target currency.

In the Target Currency dropdown list, select the required value.

SAP HANA Modeling Guide


134 PUBLIC Working With Attributes and Measures
Value Description

Fixed Select the target currency value from the currency table. Provide the required value in the
value help list.

Column Attribute column available in the calculation view to provide the target currency value. Se­
lect the required value from the value help list.

Input Parameter Input parameter to provide the target currency value at runtime. Select the required input
parameter from the value help list.

For Fixed target currency type, if you have TCURC and TCURT tables (or its synonyms) in the same
SAP HANA Database Module, you can view the currency code values in the value help list along with its
description.

 Note

The tool populates the value help list only if:


○ You have the TCURC table or its synonym in the same SAP HANA Database Module or
○ You have defined a TCURR table as the Rates table in the Conversion Table section
If the value help list is not populated, you can manually enter the required display currency code.

e. Specify the exchange rate type.

In the Exchange Type dropdown list, select the required value.

Value Description

Fixed Select the exchange rate value from the currency table. Provide the required value in the
value help list.

Column Attribute calculated column available in the calculation view to provide the exchange rate
value. Select the required value from the value help list.

Input Parameter Input parameter to provide the exchange rate value at runtime. Select the required input pa­
rameter from the value help list.

For Fixed exchange type, if you have TCURW table or its synonym in the same SAP HANA Database
Module, you can view the exchange codes in the value help list along with its description.

 Note

The tool populates the value help list only if:


○ You have defined a TCURV table as the Configuration table in the Conversion Table section
If the value help list is not populated, you can manually enter the required display currency code.

f. Specify the date for currency conversion.

In the Conversion Date dropdown list, select the required value.

Value Description

Fixed Select the fixed conversion date from the calendar.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 135
Value Description

Column Attribute value available in the calculation view to provide the date for currency conversion.
Select the required value from the value help list.

Input Parameter Input parameter to provide the date for currency conversion at runtime. Select the required
input parameter from the value help list.

g. Specify the exchange rate

If you want to specify the exchange rate using a column value from the calculation view, in the
Exchange Rate value help list, select a column value.

18. Provide details specific for banking currency conversion.


If you are performing banking currency conversion, then provide these additional details.
a. In the Market Data Area dropdown list, select a value.
The market data area is a component of the primary keys of all market data in Bank Analyzer, and
therefore also a component of every interface that requests market data. This area is used for
controlling all visibility and authorization for market data. All market data is stored with a reference to a
market data area.

Value Description

Fixed Provide or select a fixed value from the value help list.

Column Attribute value available in the calculation view to provide the market data area. Select the
required value from the value help list.

For Fixed market data area, if you have F4_FXRATES table (or its synonym) in the same SAP HANA
Database Module, you can view the market data area values in the value help list.

b. In the Conversion Type dropdown list, select a value.

Value Description

Fixed Select the required conversion type from the value help list.

Mid: The average exchange rate calculated using the bid rate and ask rate.

Bid: The rate that a bank is willing to pay for goods, foreign currency, or securities.

Ask: The rate at which goods, foreign currency, or securities are offered for sale.

Column Attribute value available in the calculation view to provide the conversion type. Select the
required value from the value help list.

Input Parameter Input parameter to provide the required conversion type at runtime. Select the required in­
put parameter from the value help list.

c. In the System Time dropdown list, select a value.

Value Description

Fixed Select the fixed system time from the calendar that defines the system timestamp for time
travel functionality. The default value is the current system timestamp in GMT.

SAP HANA Modeling Guide


136 PUBLIC Working With Attributes and Measures
Value Description

Column Attribute value available in the calculation view to provide the system time for conversion.
Select the required value from the value help list.

19. Provide the data type of value after currency conversion.


a. In the Data Type dropdown list, select the required data type.
b. Provide the length and scale for the selected data type.
20.Generate a result currency column.
a. If you want the tool to generate a column to store the result currency conversion values, select the
Generate Column checkbox.

 Note

The result currency column isn't available in reporting tools. You can only consume them using other
calculation views to perform calculations.

21. Conversion accuracy.


In the Accuracy dropdown list, select a value to set the behavior or intermediate conversions.

Value Description

Intermediate rounding If you want the intermediate conversions to mimic ERP behavior. Intermediate
rounding is the default behavior and limits the number of digits in the intermedi­
ate currency conversions to eleven (11) digits.

Retain all possible digits If you want high accuracy in conversion results, and to retain all possible digits in
the intermediate currency conversions.

22. Manage error handling.

In the Upon Failure dropdown list, select the required value that specifies how the tool must populate data if
conversion fails.

Value Description

Fail The tool displays error for conversion failures at data preview.

Set to NULL The tool sets the values for corresponding records to NULL at data preview.

Ignore The tool displays unconverted values for the corresponding records at data preview.

23. Choose OK.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 137
4.8.2 Associate Measures with Unit of Measure

If measures in calculation views represent unit values, associate the measures with a unit of measure. This
helps to display the measure values along with the unit of measures at data preview or in reporting tools.

Prerequisites

The SAP HANA Database Module that contains the calculation view in which you are performing unit
conversions either has all tables necessary for unit conversions or has synonyms referring to the standard SAP
unit tables T006, T006D, and T006A available in other schemas.

 Note

If you are not using synonyms, the structure of the tables (table definition) in the SAP HANA Database
Module for unit conversions must be similar to the standard SAP unit tables.

Context

Associating measures with unit of measures is also necessary for unit conversions. For example, if you want to
convert a unit of a measure from cubic meters to barrels to perform volume calculations, then associate the
unit of measure with the semantic type Quantity with Unit of Measure and perform unit conversions.

Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

 Note

You can also assign associate measures in any of the Aggregation nodes with unit code values and
perform unit conversion.

3. In the editor toolbar, choose (Expand Details Panel).


4. In the Columns tab, select a measure to associate it with unit code.

5. In the menu bar, choose (Assign Semantics).


6. Choose the Assign Semantics menu option.
7. In the Semantic Type dropdown list, select Quantity with Unit Of Measure.
8. (Optional) Reuse unit conversion definition.
You can reuse the unit code values and unit conversion definition from a selected measure.

SAP HANA Modeling Guide


138 PUBLIC Working With Attributes and Measures
a. In the Reuse Semantics dropdown list, select the required measure.
The tool reuses the conversion semantics of the selected measure.
b. Select a reuse type.

Reuse Type Description

Reference Select to reuse conversion semantics of the selected measure as a reference in the unit con­
version definition of the target measure. In this reuse type, when you modify the conversion
semantics of the reference measure, the conversion semantics of the target measure auto­
matically points to the updated conversion semantics.

Copy Select to reuse by copying the conversion semantics of the selected measure to the conver­
sion definition of the target measure. In this reuse type, modifying the conversion semantics
of the selected measure does not modify the conversion semantics of the target measure.

The tool populates the Assign Semantics dialog box with unit code and unit conversion definition
associated with the selected measure.

9. Select a display unit value.

The tool displays the measure values with this unit in reporting tools.
a. In the Display Unit dropdown list, select a value.

Value Description

Fixed Associate the measure with a unit code available in the unit table. This table has a struc­
ture similar to any of the standard SAP unit tables, T006, T006A, or T006D.

Column Associate the measure with an attribute column available in the calculation view.

b. In the value help list, select the required value based on the selected display unit type.
For Fixed display unit type, if you have T006 and T006A tables (or its synonyms) in the same SAP
HANA Database Module, you can view the unit code values in the value help list along with its
description.

 Note

The tool populates the value help list only if:


○ You have defined a T006 table as the Rates table in the Conversion Table section or in the same
SAP HANA Database Module.
If the value help list is not populated, you can manually enter the required display currency code.

c. Choose OK.

10. Enable conversion.


a. If you want to convert the unit measure value to another unit, select the Conversion checkbox.
11. Specify the unit tables to refer for unit conversion.
a. In the Rates value help list, select a table that provides the unit conversion information.

This table either is a synonym to the SAP unit table, T006, or has a structure similar to standard SAP
unit table, T006.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 139
b. In the Dimension value help list, select a table that provides information on dimensions.

This table either is a synonym to the SAP unit table, T006D, or has a structure similar to standard SAP
unit table, T006D.
12. Provide additional details for unit conversions.
a. Choose the Definition tab.
b. In the Client dropdown list, select the required value that the tool must use for unit conversion factors.

Value Description

Fixed Set a fixed client value or select a session client for unit conversion factors. Provide the re­
quired value in the value help list.

Column Attribute column available in the calculation view to provide the client value. Select the re­
quired value from the value help list.

Input Parameter Input parameter to provide the client value to the tool at runtime. Select the required input
parameter from the value help list.

c. Specify the source unit.

In the Source Unit dropdown list, select the required value.

Value Description

Fixed Select the source unit value from the unit tables. Provide the required value in the value help
list.

Column Attribute column available in the calculation view to provide the source unit value. Select the
required value from the value help list.

For Fixed source unit type, if you have T006 and T006A tables (or its synonyms) in the same SAP
HANA Database Module, you can view the unit code values in the value help list along with its
description.

 Note

The tool populates the value help list only if:


○ You have defined a T006 table as the Rates table in the Conversion Table section or in the same
SAP HANA Database Module.
If the value help list is not populated, you can manually enter the required display currency code.

d. Specify the target unit.

In the Target Unit dropdown list, select the required value.

Value Description

Fixed Select the target unit value from the unit tables. Provide the required value in the value help
list.

Column Attribute column available in the calculation view to provide the target unit value. Select the
required value from the value help list.

SAP HANA Modeling Guide


140 PUBLIC Working With Attributes and Measures
Value Description

Input Parameter Input parameter to provide the target unit value to the tool at runtime. Select the required
input parameter from the value help list.

For Fixed target unit type, if you have T006 and T006A tables (or its synonyms) in the same SAP HANA
Database Module, you can view the unit code values in the value help list along with its description.

 Note

The tool populates the value help list only if:


○ You have defined a T006 table as the Rates table in the Conversion Table section or in the same
SAP HANA Database Module.
If the value help list is not populated, you can manually enter the required display currency code.

13. Error handling.

In the Upon Failure dropdown list, select the required value that specifies how the tool must populate data if
conversion fails.

Value Description

Fail The tool displays error for conversion failures at data preview.

Set to NULL The tool sets the values for corresponding records to NULL at data preview.

Ignore The tool displays unconverted value for the corresponding records at data preview.

14. Generate result unit column.


a. If you want the tool to generate a column to store the result unit conversion values, select the Generate
checkbox.

 Note

The result unit column isn't available in reporting tools. You can only consume them using other
calculation views to perform calculations.

15. Choose OK.

4.8.3 Reuse a Currency Conversion or Unit Conversion


Definition

Reuse the currency conversion or unit conversion definition of a selected measure in multiple other measures.

Context

When reusing the conversion semantics of a measure, you apply it as a reference to multiple other measures at
a time.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 141
Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. In the Columns tab, select a measure for which you have already enabled and defined currency conversion
or unit conversion.

5. In the menu bar, choose (Assign Semantics).


6. Choose Apply Conversion Reference.
The tool displays the conversion semantics for the selected measure.

 Note

If you have not defined any conversion semantics for the selected measure, first define conversion
semantics for the measure. You can then reuse it to define conversion semantics of other target
measures. In the Reuse Semantics dropdown list, select a measure and reuse the conversion semantics
of that measure, or define new conversion semantics.

7. Choose Next.
8. Select all target measures in which you want to reuse the conversion semantics.
9. (Optional) Override conversion semantics.
For any of the selected target measure, if you have already defined currency conversion or unit conversion
(conversion semantics already exists), you can override the conversion semantics.
a. Select the Override Existing Conversion Properties checkbox.
10. Choose Finish.

4.8.4 Tag Measures as Converted or Unconverted Values

If you have associated a measure with a currency code to perform a decimal shift or currency conversion, the
tool tags the measure as converted value. Tagging helps other client tools that consume the calculation view to
identify all such converted values in the calculation view.

Context

The tool allows you to tag measures as converted or unconverted. Tagging help users depending on how the
client tools consume the measures with conversion semantics. For example, composite BW providers that
consume the calculation view performs decimal back shifting. So, if you have already defined conversion
semantics with decimal shifting for certain measures in the calculation view, it could lead to double shifting
(once in the SAP HANA view, then back shifting in the composite provider and finally shifting again in the BW
ABAB stack).

SAP HANA Modeling Guide


142 PUBLIC Working With Attributes and Measures
Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the Columns tab.
By default, for all measures, the column property, Unconverted is selected. But, if you have defined any
currency conversion semantics for a measure, then tool sets the Unconverted column property of that
measures as False (deselected).

 Tip

If this column property is not visible in the display, in the menu bar, choose (Customize Column
Display) to select and customize the display with the required column properties.

5. (Optional) Select or unselect the column property for a measure depending on whether you want to tag
them as unconverted or converted.

 Remember

You can also tag a measure for which you have defined conversion semantics as unconverted. It
depends on how you want the client tools to consume the measures.

4.9 ORDER BY and Sort the Result Set

Users can use one or more output columns of a calculation view to ORDER BY and sort the result set of a
calculation view.

Context

After modeling a calculation view and defining its output columns, the tool allows you to specify a set of output
columns as ORDER BY columns. It also allows you to define a sort direction (Ascending or Descending) to sort
the result set. When you execute a query on a calculation view or at data preview, the tool uses these ORDER
BY columns to sort the result set.

Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 143
3. In the editor toolbar, choose (Expand Details Panel).
4. Choose the Columns tab.

5. In the menu bar, choose (Sort Result Set).


6. Define the ORDER BY columns and the sort direction.
In the Sort Result Set dialog box, you can select one or more output columns of a calcution view as ORDER
BY columns and specify the sort direction.
a. In the menu bar, choose + to add an ORDER BY column.
You can add one or more output columns as ORDER BY columns.
b. In the Name dropdown list, select an output column as an ORDER BY.
c. In the Sort Direction dropdown list, select a value.
The tool uses ascending as the default sort direction.
d. Choose OK.

4.10 Mask Column Values in Client Tools

Define data masking for column values when modeling a calculation view. It helps to mask confidential column
values in the client tools. The tool supports defining data masking for column values in a way that they appear
either completely masked or partially masked in the client tools.

Context

For example, if you want the credit card details to be confidential and not be visible in client tools, then define
data masking for the column that contains credit card details.

Example for complete data masking of column values

● Unmasked Data: 1234-5678-9101-1121


● Masked Data: XXXX-XXXX-XXXX-XXXX

Example for partial data masking of column values

● Unmasked Data: 1234-5678-9101-1121


● Masked Data: 1234-5678-XXXX-XXXX

 Note

You can apply data masking for columns of type VARCHAR and NVARCHAR only.

You define data masking for individual columns using an expression, and based on the masking expression, the
query results contain only masked values. You can define data masking only for visible columns and not for any
hidden columns in the calculation view.

SAP HANA Modeling Guide


144 PUBLIC Working With Attributes and Measures
 Note

Only users with the object privilege, UNMASKED can view unmasked (original) column values.

Procedure

1. Open the required calculation view in the view editor.


2. In the view editor, select the Semantics node.
3. Choose the Columns tab.
4. Select the required column for which you want to define data masking.

5. In the toolbar, choose (Data Masking).


6. Provide data masking expression.
In the Data Masking Expression dialog box, provide the masking expression. The masking expression can
be a simple SQL expression, or can also be based on built-in functions or scalar user-defined functions.
a. In the expression editor, provide the SQL expression, which defines the data masking required for the
selected column.
Use the elements and built-in functions (SQL functions) from the dialog box to define your expression.
7. (Optional) Select Validate Syntax to validate the expression or the scalar user-defined function.
8. Choose OK.

 Note

You cannot use nested expressions to define data masking for columns.

Example

Consider a column, ACCOUNTNUMBER that contains account numbers of customers. The account number is an
eleven digit number, and assume that you want to partially mask the column values in client tools. The
expression CONCAT(LEFT("ACCOUNTNUMBER",4),'XXXXXXX') help to mask the last seven digits of account
number values and only displays the first four digits.

Account Number: 12345678965 (Before masking)

Account Number: 1234XXXXXXX (After data masking)

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 145
4.11 Assign Value Helps for Attributes

Assign a value help to an attribute column in a calculation view at design time. The value help can include
attribute values from the same calculation view or from a different calculation view.

Context

Assigning value helps for attributes are useful, especially in multidimensional calculation views. For example,
consider you have defined an input parameter in calculation view CV1 using the attribute CUSTOMER_ID. If you
want to provide values to the input parameter using the attribute CUSTOMER_ID of calculation view CV2, assign
a value help to the attribute in CV1 with the reference column, CUSTOMER_ID of CV2.

Procedure

1. Select the Semantics node.

2. In the editor toolbar, choose (Expand Details Panel).


3. Choose the Columns tab.
4. Select an attribute.

5. Choose (Assign Semantics).


6. Choose the Assign Value Help menu option.
7. Select a calculation view or table.
a. In the View/Table Value Help field, select the required calculation view or table that you want to use for
providing values.
8. Select an attribute.

The tool displays attributes that are available in the selected table or calculation view.

a. In the Reference Column dropdown list, select an attribute.


b. Choose OK.

Results

At runtime, the tool provides a value help, which has values from the selected attribute. You can use these
attribute values for input parameters and variables.

SAP HANA Modeling Guide


146 PUBLIC Working With Attributes and Measures
4.12 Enable or Disable Attributes for Drilldown in Reporting
Tools

By default, the tool lets you to drilldown the attributes or calculated attributes in the reporting tools. You can
disable this behavior for selected attributes.

Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the Columns tab.
5. Select an attribute.
6. In the Drill Down Enablement dropdown list, select a value.

Set the value to blank if you want to disable drilldown for the selected attribute.

4.13 Handle Null Values in Columns

Define default values for columns (both attributes and measures) when no value is provided during a SQL
INSERT operation. The system uses these default values in the reporting tools to replace any null values in
columns.

Context

Columns, both attributes and measures can contain undefined values or null values. You can handle such cases
by defining default values that replaces the null values in reporting tools. For example, you can replace the
column values that appear with null value representation, ? (question mark) with default value Null or with any
other user defined value.

Procedure

1. Open the calculation view in the view editor.


2. Select the Semantics node.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 147
3. In the editor toolbar, choose (Expand Details Panel).
4. Choose the Columns tab.
5. Select a measure or attribute.
6. Select the Null Handling checkbox.

 Note

Configure default column properties display.

Null handling is a column property. Use the horizontal scroll bar to view all available column properties

for a column. If you do not see Null Handling checkbox, choose the (Customize Column Display)
icon in the menu bar and ensure that you have selected the Null Handling column property.

7. In the Default Value text field, provide a default value.

 Note

If you have enabled null handling for columns, and if you have not provided any default value, the tool
considers the integer 0 as the default value for columns. For columns of data type VARCHAR and
NVARCHAR, if you have not defined a default value after enabling null handling, the tool considers empty
string as the default value.

4.14 Set Presentation Scale for Measures

For measures with numerical data types, you can set the scaling factor that the client tools can interpret and
use to present measure values.

Context

The tool stores the presentation scale value for measures in the SCALE column of the
BIMC_DIMENSION_VIEW_HDI table. It is just a static metadata that the client tools can interpret. For example,
if the presentation scale is set to 6, it means a value of 12000000 would be displayed as 12 in the client tools.
This value is arrived at by computing 12000000/10^6.

 Note

The presentation scale that you set when modeling a calculation view does not impact the data preview in
the SAP HANA Database Explorer.

SAP HANA Modeling Guide


148 PUBLIC Working With Attributes and Measures
Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the Columns tab.
5. Select the required measure.
6. In the Presentation Scale text field, set a value.

If the Presentation Scale column property is not visible in the display, in the menu bar, choose
(Customize Column Display) to select and customize the display with the required column properties.

4.15 Convert Attribute Values to Required Formats

Assign conversion functions to attribute columns. These functions help maintain conversion from any internal
to external format and from any external to internal format.

Context

For each attribute column, or input parameters or variables, you can assign two scalar functions. These
functions help maintain conversion of values to required formats. For example, the ABAP table stores data in
YYYYMMDD format. You can use a scalar function that converts the internal value, 20160503 to 2016.05.03
and use the new formatted value for reporting purposes.

You can also preserve the order of value, for example, see the following table:

Stored Data Type Format Stored Value Formatted Value Preserving Order

ABAP Date 20160503 05.03.2016 No

ABAP Date 20160503 2016.05.03 Yes

The following are example scenarios where you can use scalar functions to convert and format values

● If you want to display attribute values in the reporting tools in a specific format, but these values are stored
internally in a different format.
● If you want to provide values to filters, variables or parameters in a specific format, but internally these
values are stored in different formats.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 149
Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the Columns tab.
5. Select an attribute.

6. In the Semantics pane, choose (Conversion Function).


7. Assign conversion functions.

a. If you want to use a scalar function to format any internally stored value, in the Internal to External field
provide the required scalar function.
Use the Find Data Sources dialog box to search for the required scalar function.
b. If you want to format an external value, for example, variables or input parameters, in the External to
Internal field provide the required scalar function.

Use the Find Data Sources dialog box to search for the required scalar function.

Variables and parameters of type column implicitly inherit the conversion properties.
c. If you want to preserve the order, for example, 20150305 as 2015.03.05, select the Preserve Order
checkbox.
d. Choose OK.
8. Assign conversion functions to parameters and variables.
You can also explicitly assign conversion functions to input parameters and variables. For example, for
input parameters of type derived, static list, direct, and more.
a. Select the Parameters tab.
b. Select the required input parameter or variable.
c. In the Conversion Function section, assign the required function.
d. If you want to preserve the order, for example, 20150305 as 2015.03.05, select the Preserve Order
checkbox.

 Note

These functions are not applied in the database layer. It is used for providing hints to analytic clients on
how to convert values before displaying them in the client user interface (UI).

SAP HANA Modeling Guide


150 PUBLIC Working With Attributes and Measures
4.16 Associate Attributes with Other Related Attributes

Associate attribute columns in a calculation view with its one or more related attributes from the same
calculation view.

Context

Associating an attribute column with other related attribute columns help tag a set of attributes that provide
additional information for the target attribute column. For example, you can associate the attribute column
PRODUCT_ID with attributes such as Width, Height, Length, Price, and so on. The system internally stores the
attribute relations in the BIMC_ATTRIBUTE_RELATIONS table.

 Remember

Associating attributes with other related attributes does not impact the output of a calculation view. It is
only relevant for the interpretation of client tools (frontend tools) that consume the calculation view.

Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the Columns tab.
5. Select an attribute.
6. Select the Related Attributes value help.

 Note

Configure default column properties display.

Related attributes are a column property. Use the horizontal scroll bar to view all available column

properties for a column. If you do not see Related Attributes value help, choose the (Customize
Column Display) icon in the menu bar and ensure that you have selected the Related Attributes column
property.

7. Select the required attributes with which you want to associate the target attribute.
8. Choose OK.

SAP HANA Modeling Guide


Working With Attributes and Measures PUBLIC 151
4.17 Group Related Measures and Attributes

Create folders in calculation views to logically group related measures or related attributes in a calculation view.
For example, you can group planned measures and actual measures in separate folders.

Context

A single calculation view contains multiple measures and multiple attributes. While modeling your calculation
view, you can create a Display Folder to group the related measures and related attributes within them. You can
also create multiple folders within a single display folder.

Procedure

1. Open the required calculation view in the view editor.


2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the Columns tab.

5. In the Semantics pane menu bar, choose (Display Folder).


The Display Folder dialog box displays the list of measures and attributes in the calculation view and a
folder structure.
6. Create a new display folder.

a. In the Display Folder dialog box, select the folder and choose (Display Folder).
You can create more than one display folder. If you want to create a folder within another display folder,

select the required folder and choose (Display Folder).


b. Double-click the folder to edit the folder name.
7. Group related measures
a. From the Measure section, drag and drop the required measures to the folder in which you want to
group them.
8. Group related measures
a. From the Attributes section, drag and drop the required attributes to the folder in which you want to
group them.
9. Choose OK.

SAP HANA Modeling Guide


152 PUBLIC Working With Attributes and Measures
5 Working With Calculation View Properties

While modeling calculation views, you can define certain properties for the calculation views so that the tool
can refer to those values and run the view respectively.

For example, you can define a property, which controls how the tool must access the data from the database or
identify how to execute the calculation view, and more. This section describes the commonly used calculation
view properties, the possible values for each property, and how these values help the tool determine the
activation or execution behavior of the calculation view.

For defining the view properties, select the Semantics node and define the properties in the View Properties tab.

Related Information

Filter Data for Specific Clients [page 153]


Invalidate Cached Content [page 155]
Deprecate Calculation Views [page 157]
Quick Reference: Calculation View Properties [page 158]
Enable Calculation Views for Time Travel Queries [page 154]

5.1 Filter Data for Specific Clients

Obtain data from all clients or filter the calculation view data either with fixed client value or with session client
value set for the user.

Context

In SAP Web IDE, for filtering data for specific clients, explicitly specify the client filter column for each data
source in the calculation view. Select the required data source in the calculation view, and in the Mapping tab,
use the Client Column value help list to explicitly specify the client filter value for the selected data source.

Procedure

1. Open the calculation view in the view editor.


2. Edit view properties.

SAP HANA Modeling Guide


Working With Calculation View Properties PUBLIC 153
a. Select the Semantics node.

b. In the editor toolbar, choose (Expand Details Panel).


c. Choose the View Properties tab.
d. Choose General.
e. In the Default Client dropdown list, select a value.

Related Information

Default Client Values [page 154]

5.1.1 Default Client Values

Assign a default client to a calculation view and filter data at runtime based on the default client value. The
following table lists the default client value types you can assign and their description.

Default Client Value Description

<blank> If you do not set any default client value, the tool does not filter the table data against any
client and you see values relevant to all clients.

Session Client If you use session client as the default client value, then at runtime, the tool filters the table
data according to the value you specify as the session client in the user profile.

Fixed Client If you want to use a fixed client value, for example, 001, then the tool filters the table data for
this client value.

5.2 Enable Calculation Views for Time Travel Queries

Time travel queries are queries against the historical states of the database. You can execute a time travel
query on a calculation view to query data for a specified time in past.

Context

If you have enabled time travel for calculation views, you can view data for a specific time in the past using the
AS OF SQL extension. For example, you can execute the following SQL statement on calculation views as a
timestamp query:

select * from <calculation_view> AS OF TIMESTAMP <timestamp>

SAP HANA Modeling Guide


154 PUBLIC Working With Calculation View Properties
SAP HANA supports creating history tables. These tables help associate time-related information to your data.

When you use history tables as data sources in calculation views, it is necessary to specify a parameter that
you want to use to provide the timestamp to the time-travel queries at runtime.

Procedure

1. Open the required calculation view in the view editor.


2. Edit view properties.
a. Select the Semantics node.

b. In the editor toolbar, choose (Expand Details Panel).


c. Choose the View Properties tab.
d. Choose General.
e. If you want to enable the history, select Enable History checkbox.
f. In the History Input Parameter dropdown list, choose an input parameter.
You use input parameters to specify the timestamp in time travel queries.

 Note

Use input parameters with data type DATE or SECONDDATE or TIMESTAMP or VARCHAR(8) of
semantic type DATE to specify the timestamp.

5.3 Invalidate Cached Content

In order to maintain the significance of data cached for your calculation views, the tool supports time-based
cache invalidation and transaction-based cache invalidation.

Prerequisites

You have enabled support for cache invalidation for the required calculation view.

Context

In time-based cache invalidation, the system invalidates or removes the data from the cache after specific time
intervals. Time-based cache invalidation is necessary to refresh data after every specific time period. By
default, the cache invalidation period is null. This means, the result of the complex query that you execute
resides in the cache until you execute the next query. Similarly, if you set your cache invalidation period as one

SAP HANA Modeling Guide


Working With Calculation View Properties PUBLIC 155
hour, the result of the query resides in the cache for one hour, and system does not clear the cache for all other
queries that you execute until this time period.

In transaction-based cache invalidation, the system invalidates the cache whenever the underlying data is
modified.

 Note

Cache invalidation is applicable only to complex SQL queries that are executed on top of your calculation
views.

Procedure

1. Open the calculation view in the editor.


2. Edit view properties.
a. Select the Semantics node.

b. In the editor toolbar, choose (Expand Details Panel).


c. Choose the View Properties tab.
d. Choose Advanced.
e. In the Cache Invalidation Period dropdown list, select a value.

Related Information

5.3.1 Enabling or Disabling Result Set Caching

You can enable or disable the result set caching using the SAP HANA database explorer.

Use the following SQL queries to enable or disable caching in the system configuration.

Enabling result set caching

 Source Code

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM')


SET ('cache', 'resultcache_enabled') = 'yes' WITH RECONFIGURE;

Disabling result set caching

 Source Code

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM')


SET ('cache', 'resultcache_enabled') = 'no' WITH RECONFIGURE;

SAP HANA Modeling Guide


156 PUBLIC Working With Calculation View Properties
 Caution

The result cache doesn't work in the following cases.

● For unfolded queries.


● If view contains volatile functions
● If the calculation view is built using table functions.

For more details, see 2014148

5.4 Deprecate Calculation Views

Deprecated calculation views signify that although a calculation view is supported for modeling activities within
the tool, we recommend not to use it in other calculation views or in analytic privileges.

Context

As a data modeler, because of various reasons, you can deprecate calculation views, which you do not
recommend for use in other calculation views or analytic privileges. This helps other users or data modelers
using this calculation view know that the view is deprecated or not recommended for use.

Procedure

1. Open the required calculation view in the view editor.


2. Edit view properties.
a. Select the Semantics node.

b. In the editor toolbar, choose (Expand Details Panel).


c. Choose the View Properties tab.
d. Choose General.
e. Select the Deprecate checkbox

Results

The tool displays a warning in the menu bar of the view editor for those calculation views or analytic privileges
that are either deprecated or modeled with deprecated calculation views.

SAP HANA Modeling Guide


Working With Calculation View Properties PUBLIC 157
5.5 Quick Reference: Calculation View Properties

While modeling a calculation view, you can define values for calculation view properties. These values
determine the behavior of a calculation view at runtime.

When you are modeling calculation views, you can define the following properties in the View Properties tab of
the Semantics node.

General Properties Description

Data Category The value of this property determines whether your calculation view supports analysis with mul­
tidimensional reporting. For more information, see Supported Data Categories for Calculation
Views [page 91].

Run With The value of this property helps the tool identify the authorization it has to use while selecting
the data from the database and for executing the calculation view or procedure. If the property is
set to Definer’s Rights, the tool uses the authorizations of the user who defines the view or proce­
dure. Similarly, if the property is set to Invoker’s Rights, then the tool uses the authorizations of
the current user to access data from the database.

Default Client The value of this property determines whether the tool must filter the calculation view data
based on a fixed client value, a session client value, or <blank> (does not filter data) at runtime.
For more information, see Filter Data for Specific Clients [page 153]

Apply Privileges The value of this property specifies the analytic privilege type selected for data access restric­
tions on the calculation view. For more information, see Defining Data Access Privileges [page
161].

Default Member The value of this property helps the tool identify the default member for all hierarchies in the cal­
culation view.

Count Star Column The value of this property is set to row.count in calculation views, which were created by migrat­
ing analytic views having the row.count column. The row.count column was used internally to
store the result of SELECT COUNT(*) queries.

You can also select a column from the calculation view as Count Star Column. In this case, the
column you select is used to store the result of SELECT COUNT(<column_name>).

Deprecate The value of this property determines whether a user does not recommend using the calculation
view in other modeler objects. If the value is set to True, it indicates that although the calculation
view is supported for modeling activities, we recommend not to use. For more information, Dep­
recate Calculation Views [page 157].

Enable Hierarchies for This view property is applicable only for calculation views with star join. The value of this prop­
erty helps the tool identify whether you have enabled SQL access to shared hierarchies. For more
SQL access
information, see Query Shared Hierarchies [page 127]

SAP HANA Modeling Guide


158 PUBLIC Working With Calculation View Properties
General Properties Description

Enable History The value of this property determines whether you can execute time travel queries on the se­
lected calculation view. If the property is set to True, you can execute time travel queries on the
calculation view. For more information, see Enable Calculation Views for Time Travel Queries
[page 154].

History Input Parameter Input parameter that specifies the timestamp in time-travel queries.

Partition by Local Execu­ For data source (tables only) and union view nodes, you can set the Partition Local Execution flag.
Select the data source and in the Properties section, you can set the Partition Local Execution
tion
flag and select the required partition column..

When the flag is set to True, the engine executes the calculation view in parallel threads based on
the partition defined for the tables. These parallel threads are combined in the union view node.

 Remember
● The flag is applicable only for tables as data sources (or synonyms pointing to tables).
● The table data source is part of the union view node either directly or through inter­
mediate view nodes.
● The union view node has only one data source.
● The flag does not work when used with unfolding behavior.

Advanced Properties Description

Propagate Instantiation The value of this property helps the tool identify whether it has to propagate the instantiation
to SQL Views handled by the calculation engine to the CDS or SQL views built on top of this calculation view. If
the value is set to True, the tool propagates the instantiation to the CDS or SQL views. This
means that, attributes that a query (on a SQL view built on top of this view) does not request are
pruned and not considered at runtime.

For information on calculation engine instantiation process, see SAP Note 1764658 .

Cache The value of this property determines whether you want to cache the result sets. By default the
results of a query that you execute on a calculation view for which the flag Cache are set remain
in the cache until either the underlying data have changed (Cache Invalidation Period “Transac­
tional”), or the selected invalidation period (for example, one day) has expired. For more infor­
mation, see Enabling or Disabling Result Set Caching [page 156]

Analyticview Compatibil­ The value of this property helps the join engine identify whether it has to ignore joins with N:M
ity Mode cardinality, when executing the join. For a star join in which no filters are defined, and if the left
table and the right table of the join does not request for any field, then the join engine prunes the
N:M cardinality joins, when the Analyticview compatibility mode property is set to true.

Pruning Configuration The value of this property determines the pruning configuration table that the tool must use to
Table prune data in union nodes. For more information, see Prune Data in Union Nodes [page 48].

Execute In The value of this property impacts the output data. It determines whether the tool must execute
the calculation view in SQL engine or column engine. For more information, see 1857202 .

SAP HANA Modeling Guide


Working With Calculation View Properties PUBLIC 159
Advanced Properties Description

Cache Invalidation Pe­ The value of this property impacts the output data. It determines the time interval to invalidate
riod or remove the cached content. For more information, see Invalidate Cached Content [page 155].

Execution Hints For more information on execution hints, see 2142945

SAP HANA Modeling Guide


160 PUBLIC Working With Calculation View Properties
6 Defining Data Access Privileges

Use the analytic privilege editor in the SAP Web IDE to create analytic privileges.

You create analytic privileges to grant different users access to different portions of data in the same view
based on their business role. Within the definition of an analytic privilege, the conditions that control which
data users see is defined using SQL.

Standard object privileges (SELECT, ALTER, DROP, and more) implement coarse-grained authorization at
object level only. Users either have access to an object, such as a table, view or procedure, or they don't. While
this is sufficient, there are cases when access to data in an object depends on certain values or combinations of
values. Analytic privileges are used in the SAP HANA database to provide such fine-grained control at row level
of which data individual users can see within the same view.

Example

Sales data for all regions is contained within one calculation view. However, regional sales managers should
only see the data for their region. In this case, an analytic privilege could be modeled so that they can all query
the view, but only the data that each user is authorized to see is returned.

Related Information

Create Static SQL Analytic Privileges [page 161]


Create Dynamic SQL Analytic Privileges [page 164]
Create Analytic Privileges Using SQL Expressions [page 165]
Structure of SQL-Based Analytic Privileges [page 167]

6.1 Create Static SQL Analytic Privileges

For creating static SQL analytic privileges, you use attribute columns from views to define fixed restrictions on
data access. These restrictions are defined in the analytic privilege editor at design time.

Prerequisites

1. If you want to use a SQL analytic privilege to apply data access restrictions on calculation views, set the
Apply Privileges property for the calculation view to SQL Analytic Privileges.

SAP HANA Modeling Guide


Defining Data Access Privileges PUBLIC 161
1. Open the calculation view in the view editor.
2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the View Properties tab.
5. Choose General.
6. In the Apply Privileges dropdown list, select SQL Analytic Privileges.
2. If you want to use a SQL analytic privilege to apply data access restrictions on CDS views, you have defined
the referenced CDS views using the WITH STRUCTURED PRIVILEGE CHECK clause.

Procedure

1. Start SAP Web IDE in a Web browser.


2. If you want to create a new project for the calculation view, do the following:

a. In SAP Web IDE, choose File New Project from Template .


b. Choose the project template type.

Currently, there is only one type of project template available, namely: Multi-Target Application Project.
Select Multi-Target Application Project and choose Next.
c. Type a name for the new MTA project (for example, myApp and choose Next to confirm).
d. Specify details of the new MTA project and choose Next to confirm.
e. Create the new MTA project; choose Finish.
3. Select the SAP HANA Database Module in which you want to create the analytic privilege.
4. Browse to the src folder.

5. In the context menu, choose New Analytic Privilege .


6. Enter the details for the new analytic privilege.
a. In the Name field, enter the name of the analytic privilege.
7. Choose Create.
The tool opens the analytic privilege editor where you can define the analytic privilege.
8. Select models to define the scope of the analytic privilege.

If you want to create an analytic privilege and apply the data access restrictions for selected list of models,
in the Secured Models section add the required models,
a. Choose + (Add).
b. In the Find Data Sources dialog box, search and select the models for which you want to apply the
analytic privilege restrictions.

 Note

You can only add calculation views and CDS views to the secured models list.

c. Choose Finish.
9. Define the validity.
In the Attribute pane, expand the PRIVILEGE VALIDITY section to specify the time period for which the
analytic privilege is valid. You can specify multiple time periods for which the analytic privilege is valid.

SAP HANA Modeling Guide


162 PUBLIC Defining Data Access Privileges
a. In the PRIVILEGE VALIDITY, choose + (Add).
b. In the Operator dropdown list, select the required operator.
c. Based on the selected operator, specify the time period (From and To) for which the analytic privilege
is valid.
10. Define the attribute restrictions.
The tool uses the restrictions defined on the attributes to restrict data access. Each attribute restriction is
associated with only one attribute, but can contain multiple value filters. You can define more than one
attribute restriction.
a. In the Associated Attribute Restrictions section, choose + (Add).
b. In the Attributes dropdown list, select the required attribute.

c. In the Restriction Type dropdown list, choose .


You can add more than one restriction for a single attribute.
d. Select the required operator to define the condition.
e. In the Value field, specify the required value.
11. Define attribute restrictions using hierarchy node column.
You can define hierarchy analytic privileges only if you have enabled SQL access to shared hierarchies.

For example, if you have enabled SQL access to shared hierarchies and if SalesRepHierarchyNode is the
node column that the tool generates for a parent-child hierarchy, then "SalesRepHierarchyNode" =
"MAJESTIX" is a possible filter expression in analytic privileges.
a. In the Hierarchy Privilege section, choose + (Add).
b. In the Hierarchy dropdown list, select a hierarchy.
c. In the Value field, provide a node column value.

 Note

You can create hierarchical analytic privileges only for the following conditions:
○ All models in the Secured Models are star join calculation views with shared dimensions.
○ You have enabled SQL access to the shared hierarchies in star join calculation views.

12. Build an SAP HANA Database Module.


The build process uses the design-time database artifacts to generate the corresponding actual objects in
the database catalog.
a. From the module context menu, choose Build.
13. Assign privileges to a user.

Related Information

Structure of SQL-Based Analytic Privileges [page 167]

SAP HANA Modeling Guide


Defining Data Access Privileges PUBLIC 163
6.2 Create Dynamic SQL Analytic Privileges

Dynamic SQL analytic privileges determine the filter condition string to restrict data access at runtime. You use
the analytic privilege editor to define the dynamic SQL analytic privilege.

Prerequisites

1. If you want to use a SQL analytic privilege to apply data access restrictions on calculation views, set the
Apply Privileges property for the calculation view to SQL Analytic Privileges.
1. Open the calculation view in the view editor.
2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the View Properties tab.
5. Choose General.
6. In the Apply Privileges dropdown list, select SQL Analytic Privileges.
2. If you want to use a SQL analytic privilege to apply data access restrictions on CDS views, you have defined
the referenced CDS views using the WITH STRUCTURED PRIVILEGE CHECK clause.

Procedure

1. Start SAP Web IDE in a Web browser.


2. If you want to create a new project for the calculation view, do the following:

a. In the SAP Web IDE, choose File New Project from Template .
b. Choose the project template type.

Currently, there is only one type of project template available, namely: Multi-Target Application Project.
Select Multi-Target Application Project and choose Next.
c. Type a name for the new MTA project (for example, myApp and choose Next to confirm).
d. Specify details of the new MTA project and choose Next to confirm.
e. Create the new MTA project; choose Finish.
3. Select the SAP HANA Database Module in which you want to create the analytic privilege.
4. Browse to the src folder.

5. In the context menu, choose New Analytic Privilege .


6. Enter the details for the new analytic privilege.
a. In the Name field, enter the name of the analytic privilege.
7. Choose Create.
The tool opens the analytic privilege editor where you can define the analytic privilege. By default, it opens
the editor to define static SQL analytic privileges.
8. Switch analytic privilege editor view.

SAP HANA Modeling Guide


164 PUBLIC Defining Data Access Privileges
a. In the analytic privilege editor, choose (Privilege Types).
b. Choose the Dynamic menu option.
c. In the Procedure value help list, search for the required procedure.
The procedure helps define the filter conditions in the dynamic SQL analytic privilege.
d. Choose Finish.
9. Build an SAP HANA Database Module.
The build process uses the design-time database artifacts to generate the corresponding actual objects in
the database catalog.
a. From the module context menu, choose Build.
10. Assign privileges to a user.

Related Information

Structure of SQL-Based Analytic Privileges [page 167]

6.3 Create Analytic Privileges Using SQL Expressions

The analytic privilege editor provides you the flexibility to create SQL based analytic privileges using the
familiar SQL environment. You can create both static and dynamic SQL analytic privileges by writing relevant
SQL expressions.

Prerequisites

1. If you want to use a SQL analytic privilege to apply data access restrictions on calculation views, set the
Apply Privileges property for the calculation view to SQL Analytic Privileges.
1. Open the calculation view in the view editor.
2. Select the Semantics node.

3. In the editor toolbar, choose (Expand Details Panel).


4. Choose the View Properties tab.
5. Choose General.
6. In the Apply Privileges dropdown list, select SQL Analytic Privileges.
2. If you want to use a SQL analytic privilege to apply data access restrictions on CDS views, you have defined
the referenced CDS views using the WITH STRUCTURED PRIVILEGE CHECK clause.

SAP HANA Modeling Guide


Defining Data Access Privileges PUBLIC 165
Procedure

1. Start SAP Web IDE in a Web browser.


2. If you want to create a new project for the calculation view, do the following:

a. In the SAP Web IDE, choose File New Project from Template .
b. Choose the project template type.

Currently, there is only one type of project template available, namely: Multi-Target Application Project.
Select Multi-Target Application Project and choose Next.
c. Type a name for the new MTA project (for example, myApp and choose Next to confirm).
d. Specify details of the new MTA project and choose Next to confirm.
e. Create the new MTA project; choose Finish.
3. Select the SAP HANA Database Module in which you want to create the analytic privilege.
4. Browse to the src folder.

5. In the context menu, choose New Analytic Privilege .


6. Enter the details for the new analytic privilege.
a. In the Name field, enter the name of the analytic privilege.
7. Choose Create.
The tool opens the analytic privilege editor where you can define the analytic privilege. By default, it opens
the editor to define static SQL analytic privileges.
8. Switch analytic privilege editor view.

a. In the analytic privilege editor, choose (Privilege Types).


b. Choose the SQL Expression menu option.
c. For creating static SQL analytic privilege, in the SQL editor define the attribute restrictions and its
validity.
For example:

 Sample Code

(("REGION" = 'EAST') OR ("REGION" = 'NORTH')) AND (("CUSTOMER_ID" =


'SAP')) AND ((CURRENT_DATE BETWEEN 2015-05-15 00:00:00.000 AND
2015-05-15
23:59:59.999))

 Note

If you have enabled SQL access for calculation views (of type dimensions used in a star join
calculation view), the tool generates a node column. You can maintain a filter expression using this
node column when creating analytic privileges. For example, if SalesRepHierarchyNode is the
node column that the tool generates for a parent-child hierarchy, then
"SalesRepHierarchyNode" = "MAJESTIX" is a possible filter expression.

d. For creating dynamic SQL analytic privilege, in the SQL editor specify the procedure within the
CONDITION PROVIDER clause.
For example:

SAP HANA Modeling Guide


166 PUBLIC Defining Data Access Privileges
 Sample Code

CONDITION PROVIDER schema_name.procedure_name

9. Build an SAP HANA Database Module.


The build process uses the design-time database artifacts to generate the corresponding actual objects in
the database catalog.
a. From the module context menu, choose Build.
10. Assign privileges to a user.

6.4 Structure of SQL-Based Analytic Privileges

An analytic privilege consists of a set of restrictions against which user access to a particular attribute view,
analytic view, calculation view, or SQL view is verified. In an SQL-based analytic privilege, these restrictions are
specified as filter conditions that are fully SQL based.

SQL-based analytic privileges are created using the CREATE STRUCTURED PRIVILEGE statement:

CREATE STRUCTURED PRIVILEGE <privilege_name> FOR <action> ON <view_name>


<filter_condition>;

The FOR clause is used restrict the type of access (only the SELECT action is supported). The ON clause is
used to restrict access to one or more views with the same filter attributes.

The <filter condition> parameter is used to restrict the data visible to individual users. The following
methods of specifying filter conditions are possible:

● Fixed filter (WHERE) clause


● Dynamically generated filter (CONDITION PROVIDER) clause

Fixed Filter Clauses

A fixed filter clause consists of an WHERE clause that is specified in the definition of the analytic privilege
itself.

You can express fixed filter conditions freely using SQL, including subqueries.

By incorporating built-in SQL functions into the subqueries, in particular SESSION_USER, you can define an
even more flexible filter condition.

 Example

country IN (SELECT a.country FROM authorizationtable a WHERE SESSION_USER=


a.user_name)

SAP HANA Modeling Guide


Defining Data Access Privileges PUBLIC 167
 Note

A calculation view cannot be secured using an SQL-based analytic privilege that contains a complex filter
condition if the view is defined on top of analytic and/or attributes views that themselves are secured with
an SQL-based analytic privilege with a complex filter condition.

 Remember

If you use a subquery, you (the creating user) must have the required privileges on the database objects
(tables and views) involved in the subquery.

Comparative conditions can be nested and combined using AND and OR (with corresponding brackets).

 Tip

To create an analytic privilege that allows either access to all data or no data in a view, set a fixed filter
condition such as 1=1 or 1!=1.

Dynamically Generated Filter Clauses

With a dynamically generated filter clause, the WHERE clause that specifies the filter condition is generated
every time the analytic privilege is evaluated. This is useful in an environment in which the filter clause changes
very dynamically. The filter condition is determined by a procedure specified in the CONDITION PROVIDER
clause, for example:

 Sample Code

CREATE STRUCTURED PRIVILEGE dynamic_ap FOR SELECT ON schema1.v1 CONDITION


PROVIDER schema2.procedure1;

Procedures in the CONDITION PROVIDER clause must have the following properties:

● They must have the security mode DEFINER.


● They must be read-only procedures.
● They must have a predefined signature. Here, the following conditions apply:
○ No input parameter
○ Only one output parameter for the filter condition string of string type NVARCHAR, VARCHAR, CLOB,
or NCLOB
While VARCHAR and NVARCHAR have length limitations of 5000 characters, CLOB and NCLOB can be
used to accommodate longer filter strings.
● The procedure may only return conditions expressed with the following operators:
○ =, <=, <, >, >=
○ LIKE
○ BETWEEN
○ IN
○ NOT (...)
○ !=
A complex filter condition, that is a subquery, may not be returned.

SAP HANA Modeling Guide


168 PUBLIC Defining Data Access Privileges
 Tip

A procedure that returns the filter condition 1=1 or 1>1 can be used to create an analytic privilege that
allows access to all data or no data in a view.

● The procedure must be executable by _SYS_REPO, that is, either_SYS_REPO must be the owner of the
procedure or the owner of the procedure has all privileges on the underlying tables/views with GRANT
OPTION and has granted the EXECUTE privilege on the procedure to the _SYS_REPO user.

If errors occur in procedure execution, the user receives a Not authorized error, even if he has the analytic
privileges that would grant access.

Related Information

CREATE STRUCTURED PRIVILEGE Statement (Access Control)

6.4.1 Examples: Securing Views Using SQL-Based Analytic


Privileges

Use the CREATE STRUCTURED PRIVILEGE statement to create SQL-based analytic privileges for different
scenarios.

Context

The examples provided here take you through the following scenarios:

● Example 1: Securing a column view using an SQL-based analytic privilege with a fixed filter clause [page
170]
● Example 2: Securing an SQL view using an SQL-based analytic privilege with a complex filter clause
(subquery) [page 171]
● Example 3: Securing a column view using an SQL-based analytic privilege with a dynamically generated
filter clause [page 173]

 Note

The analytic privileges in these examples are created using the CREATE STRUCTURED PRIVILEGE
statement. Under normal circumstances, you create SQL-based analytic privileges using the SAP HANA
Web IDE. They can be granted and revoked only by the actual database user who creates them.

SAP HANA Modeling Guide


Defining Data Access Privileges PUBLIC 169
Example 1: Secure a Column View Using an SQL-Based
Analytic Privilege with a Fixed Filter Clause

Prerequisites

The database user TABLEOWNER has set up a calculation scenario based on the table SALES_TABLE, which
contains the data to be protected.

Context

All sales data is contained in a single view. You want to restrict user access so that sales managers can see only
information about the product "car" in the sales region UK and Germany. You want to do this by creating an
analytic privilege with a fixed filter clause.

A fixed filter clause consists of an SQL WHERE clause that is specified in the definition of the analytic privilege
itself.

 Tip

In the following procedure, you might find it easier to use the graphical editors to create the calculation view
and analytic privilege.

Procedure

1. Create the view containing the sales data:

CREATE COLUMN VIEW "TABLEOWNER"."VIEW_SALES" TYPE CALCULATION WITH PARAMETERS


('PARENTCALCINDEXSCHEMA'='TABLEOWNER',
'PARENTCALCINDEX'='CALCSCEN_SALES',
'PARENTCALCNODE'='SALES_TABLE',
'REGISTERVIEWFORAPCHECK'='0') STRUCTURED PRIVILEGE CHECK
;

 Note

You can see above that the authorization check using XML-based analytic privileges is disabled with
'REGISTERVIEWFORAPCHECK'='0', while the authorization check using SQL-based analytic
privileges is enabled with STRUCTURED PRIVILEGE CHECK. Both checks cannot be enabled at the
same time.

2. Create the analytic privilege:

CREATE STRUCTURED PRIVILEGE AP_SALES_1 FOR SELECT


ON TABLEOWNER.VIEW_SALES
WHERE REGION IN ('DE','UK')
OR PRODUCT = 'CAR'
;

SAP HANA Modeling Guide


170 PUBLIC Defining Data Access Privileges
 Remember

When specifying filters, remember the following:

○ You can specify only the SELECT action in the FOR clause.
○ You can specify one or more views with the same filter attributes in the ON clause
○ You can specify comparative conditions between attributes and constant values using only the
following operators:
○ =, <=, <, >, >=
○ LIKE
○ BETWEEN
○ IN
○ You can create complex filter conditions by including SQL statements as subqueries inside the
WHERE clause. Example 2 illustrates how you do this. But remember: A calculation view cannot be
secured using an SQL-based analytic privilege that contains a complex filter condition if the view is
defined on top of analytic and/or attributes views that themselves are secured with an SQL-based
analytic privilege with a complex filter condition.
Also remember that if you use a subquery, you must have the required privileges on the database
objects (tables and views) involved in the subquery.

3. Grant the SELECT privilege on the view TABLEOWNER.VIEW_SALES to the relevant users/roles:

GRANT SELECT on TABLEOWNER.VIEW_SALES to <SALES_MANAGERS>;

 Remember

Only the view owner or a user who has the SELECT privilege WITH GRANT OPTION on the view can
perform the grant.

4. Grant the analytic privilege to the relevant users/roles:

GRANT STRUCTURED PRIVILEGE AP_SALES_1 TO <SALES_MANAGERS>;

 Remember

Only the owner of the analytic privilege can grant it.

Example 2: Secure an SQL View Using an SQL-Based Analytic


Privilege with a Complex Filter Clause (Subquery)

Prerequisites

The database user TABLEOWNER has created a table TABLEOWNER.SALES, which contains the data to be
protected.

SAP HANA Modeling Guide


Defining Data Access Privileges PUBLIC 171
Context

All sales data is contained in a single view. You want to restrict access of user MILLER so that he can see only
product information from the year 2008. You want to do this by creating an analytic privilege with a complex
filter clause.

With a complex filter clause, the SQL WHERE clause that specifies the filter condition includes an SQL
statement, or a subquery. This allows you to create complex filter conditions to control which data individual
users see.

 Tip

In the following procedure, you might find it easier to use the graphical editors to create the calculation view
and analytic privilege.

Procedure

1. Create the view containing the sales data which needs to be secured:

CREATE VIEW "VIEWOWNER"."ROW_VIEW_SALES_ON_SALES" AS SELECT


* FROM "TABLEOWNER"."SALES" WITH STRUCTURED PRIVILEGE CHECK
;

 Remember

The user creating the view must have the SELECT privilege WITH GRANT OPTION on the table
TABLEOWNER.SALES.

2. Create the table containing user-specific authorization data:

CREATE COLUMN TABLE "VIEWOWNER"."AUTHORIZATION_VALUES"("VALUE" VARCHAR(256),


"USER_NAME" VARCHAR(20));

3. Insert authorization information for user MILLER:

INSERT INTO "VIEWOWNER"."AUTHORIZATION_VALUES" VALUES('2008', 'MILLER);

4. Create the analytic privilege using a subquery as the condition provider:

CREATE STRUCTURED PRIVILEGE AP_ROW_VIEW_SALES_ON_SALES FOR SELECT


ON "VIEWOWNER"."ROW_VIEW_SALES_ON_SALES"
WHERE (CURRENT_DATE BETWEEN 2015-01-01 AND 2015-01-11) AND YEAR IN (SELECT
VALUE FROM VIEWOWNER.AUTHORIZATION_VALUES WHERE USER_NAME = SESSION_USER)
;

 Remember

○ Subqueries allow you to create complex filter conditions, but remember: A calculation view cannot
be secured using an SQL-based analytic privilege that contains a complex filter condition if the
view is defined on top of analytic and/or attributes views that themselves are secured with an SQL-
based analytic privilege with a complex filter condition.
○ The user creating the analytic privilege must have the SELECT privilege on the objects involved in
the subquery, in this case table VIEWOWNER.AUTHORIZATION_VALUES.

SAP HANA Modeling Guide


172 PUBLIC Defining Data Access Privileges
○ The session user is the database user who is executing the query to access a secured view. This is
therefore the user whose privileges must be checked. For this reason, the table containing the
authorization information needs a column to store the user name so that the subquery can filter on
this column using the SQL function SESSION_USER.

 Caution

Do not map the executing user to the application user. The application user is unreliable because it is
controlled by the client application. For example, it may set the application user to a technical user or it
may not set it at all. In addition, the trustworthiness of the client application cannot be guaranteed.

5. Grant the SELECT privilege on the view VIEWOWNER.ROW_VIEW_SALES_ON_SALES to user MILLER.

GRANT SELECT ON "VIEWOWNER"."ROW_VIEW_SALES_ON_SALES" TO MILLER;

 Remember

Only the view owner or a user who has the SELECT privilege WITH GRANT OPTION on the view can
perform the grant.

6. Grant the analytic privilege to user MILLER.

GRANT STRUCTURED PRIVILEGE AP_ROW_SALES_ON_SALES TO MILLER;

 Remember

Only the owner of the analytic privilege can grant it.

Example 3: Secure a Column View Using an SQL-Based


Analytic Privilege with a Dynamically Generated
Filter Clause

Prerequisites

The database user TABLEOWNER has set up a calculation scenario based on the table SALES_TABLE, which
contains the data to be protected.

Context

All sales data is contained in a single view. You want to restrict access of user ADAMS so that he can see only
information about cars bought by customer Company A or bikes sold in 2006. You want to do this by creating
an analytic privilege with a dynamically generated filter clause.

With a dynamically generated filter clause, the SQL WHERE clause that specifies the filter condition is
generated every time the analytic privilege is evaluated. This is useful in an environment in which the filter
clause changes very dynamically.

SAP HANA Modeling Guide


Defining Data Access Privileges PUBLIC 173
 Tip

In the following procedure, you might find it easier to use the graphical editors to create the calculation view
and analytic privilege.

Procedure

1. Create the view containing the sales data:

CREATE COLUMN VIEW "TABLEOWNER"."VIEW_SALES" TYPE CALCULATION WITH PARAMETERS


('PARENTCALCINDEXSCHEMA'='TABLEOWNER',
'PARENTCALCINDEX'='CALCSCEN_SALES',
'PARENTCALCNODE'='SALES_TABLE',
'REGISTERVIEWFORAPCHECK'='0') STRUCTURED PRIVILEGE CHECK
;

2. Create a table containing user-specific filter strings:

CREATE COLUMN TABLE "AUTHORIZATION"."AUTHORIZATION_FILTERS"("FILTER"


VARCHAR(256),
"USER_NAME" VARCHAR(20))
;

3. Create an authorization filter for user ADAMS:

INSERT
INTO "AUTHORIZATION"."AUTHORIZATION_FILTERS" VALUES('(CUSTOMER=''Company A''
AND PRODUCT=''Car'') OR (YEAR=''2006'' AND PRODUCT=''Bike'')',
'ADAMS')
;

 Remember

Filters containing comparative conditions must be defined as specified in example 1.

4. Create the database procedure that provides the filter clause for the analytic privilege and grant it to object
owner of the project:

CREATE PROCEDURE "PROCOWNER"."GET_FILTER_FOR_USER"(OUT OUT_FILTER


VARCHAR(5000))
LANGUAGE SQLSCRIPT SQL SECURITY DEFINER READS SQL DATA AS
v_Filter VARCHAR(5000);
CURSOR v_Cursor FOR SELECT "FILTER" FROM
"PROCOWNER"."AUTHORIZATION_FILTERS" WHERE "USER_NAME" = SESSION_USER;
BEGIN
OPEN v_Cursor;
FETCH v_Cursor INTO v_Filter;
OUT_FILTER := v_Filter;
CLOSE v_Cursor;
END;
GRANT EXECUTE ON "PROCOWNER"."GET_FILTER_FOR_USER";

SAP HANA Modeling Guide


174 PUBLIC Defining Data Access Privileges
 Remember

When using procedures as the condition provider in an SQL-based analytic privilege, remember the
following:

○ Procedures must have the following properties:


○ They must have the security mode DEFINER.
○ They must be read-only procedures.
○ A procedure with a predefined signature must be used. The following conditions apply:
○ No input parameter
○ Only one output parameter for the filter condition string of string type NVARCHAR,
VARCHAR, CLOB, or NCLOB
While VARCHAR and NVARCHAR have length limitations of 5000 characters, CLOB and
NCLOB can be used to accommodate longer filter strings.
○ The procedure may not return a complex filter condition, that is a subquery.
○ The procedure must be executable by object owner of the project, that is, either object owner of
the project must be the owner of the procedure or the owner of the procedure has all privileges on
the underlying tables/views with GRANT OPTION and has granted the EXECUTE privilege on the
procedure to the object owner of the project.
○ The session user is the database user who is executing the query to access a secured view. This is
therefore the user whose privileges must be checked. For this reason, the table or view used in the
procedure should contain a column to store the user name so that the procedure can filter on this
column using the SQL function SESSION_USER.
○ If errors occur in procedure execution, the user receives a Not authorized error, even if he has
the analytic privileges that would grant access.

5. Create the analytic privilege using the procedure as condition provider:

CREATE STRUCTURED PRIVILEGE AP_SALES_2 FOR SELECT ON


"TABLEOWNER"."VIEW_SALES" CONDITION PROVIDER
"AUTHORIZATION"."GET_FILTER_FOR_USER";

On evaluation of the analytic privilege for user ADAMS, the WHERE clause (CUSTOMER='Company A' AND
PRODUCT='Car') OR (YEAR='2006' AND PRODUCT='Bike'), as provided by the procedure
GET_FILTER_FOR_USER, will be used.
6. Grant the SELECT privilege on the view TABLEOWNER.VIEW_SALES to user ADAMS:

GRANT SELECT on TABLEOWNER.VIEW_SALES to ADAMS;

 Remember

Only the view owner or a user who has the SELECT privilege WITH GRANT OPTION on the view can
perform the grant.

7. Grant the analytic privilege to user ADAMS:

GRANT STRUCTURED PRIVILEGE AP_SALES_2 TO ADAMS;

 Remember

Only the owner of the analytic privilege can grant it.

SAP HANA Modeling Guide


Defining Data Access Privileges PUBLIC 175
7 Additional Functionality for Calculation
Views

After modeling calculation views or during design time itself you can perform certain additional functions to
understand the performance of the view at runtime and to efficiently model calculation views.

This section describes the different additional functions that the tool offers and how you can use these
functions to efficiently model views.

Related Information

Trace Objects with Data Lineage [page 177]


Trace Dependent Objects to Analyze Impacts [page 178]
Open Calculation Views in Performance Analysis Mode [page 180]
Maintain Comments for Calculation View Objects [page 184]
Replacing Nodes and Data Sources [page 186]
Using Functions in Expressions [page 189]
Manage Calculation Views with Missing Objects [page 218]
Generate Calculation View Documentation [page 222]
Additional Functionality for Calculation Views [page 176]
Rename and Refactor Calculation Views [page 218]

7.1 Add an External Service in the mta.yaml File

You can access data sources from external services only if you have created the necessary user-provided
service (for non HDI) and configured it in the mta.yaml file. Similarly, you can access data sources from HDI
containers, only if you have configured the required HDI service in the mta.yaml file

Context

The tool enables you to use a form-based UI to create a user-provided service or to configure an existing user-
provided service in the mta.yaml file. For objects in HDI containers, use the tool to configure the required HDI
service in the mta.yaml file.

SAP HANA Modeling Guide


176 PUBLIC Additional Functionality for Calculation Views
Procedure

1. Start SAP Web IDE in a Web browser.


2. In the Workspace view, right-click the SAP HANA Database Module in which you want to configure the
mta.yaml file.

3. Choose New SAP HANA Service Connection .


4. Configuring the mta.yaml for non HDI containers.
a. In the Add External SAP HANA Service dialog box, select Non HDI Container.
b. If you want to use an existing user-provided service, select Existing User Provided Service and enter the
name of the user-provided service.
c. If you want to create a new user-provided service, in the User Provided Service Name text field, enter a
name.
d. Provide details of the SAP HANA database that the selected user-provided service refers.
e. Choose Finish.
The tool automatically creates the user-provided service and configures the mta.yaml file.
5. Configuring the mta.yaml file for HDI containers.
a. In the Add External SAP HANA Service dialog box, select HDI Container.
The tool displays the list of all HDI services.
b. Select the required HDI service that you want to configure in the mta.yaml file.
c. Choose Finish.

7.2 Trace Objects with Data Lineage

The graphical calculation view editor in SAP Web IDE supports data lineage to graphically visualize the source
of objects used for modeling a calculation view.

Context

Use data lineage to graphically visualize the flow of an object within a calculation view. With data lineage, you
can identify from where the calculation view gets its data from. For example, for a selected calculation view, you
can graphically visualize the source for its attributes, measures, underlying data sources (tables and views) and
more. Data lineage is useful, especially to analyze impacts, to trace errors, and to debug errors.

The tool supports two types of data lineage. In the first scenario, you can view the flow of an object from its
source and up to the semantics node within the calculation view. In the second scenario, you can view the
source of all data sources (tables and views) used for modeling a calculation view.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 177
Procedure

1. Trace columns in a calculation view.


a. Start SAP Web IDE in a Web browser.
b. In the Workspace view, select the required calculation view.
c. In the context menu, choose Open With Calculation View Editor .
d. Select the Semantics node.

e. In the editor toolbar, choose (Expand Details Panel).


f. Choose the Columns tab.
g. Select a column you want to trace.

h. Choose (Show Lineage).


In the same view editor, the tool highlights the selected column, its source object, and the flow of the
selected column from its source to the Semantics node.

 Note

For calculated columns, the tool displays the source of all columns used in the valid calculated column
expression, and for restricted columns, the tool displays the source of the base measure used in
defining the restricted column.

2. Trace source of all data sources within the calculation view.


a. Start SAP Web IDE in a Web browser.
b. In the Workspace view, select the required calculation views.
c. In the context menu, choose Modeling Actions Data Lineage .
In a new tab, the tool opens a new editor. You use this editor to trace the source of all data sources
used for modeling the selected calculation view. Use the collapse and expand buttons for each such
data source to view its next level details.

7.3 Trace Dependent Objects to Analyze Impacts

Modifying a calculation view can impact other calculation views that are modeled on top of the view. It is
necessary to identify all such dependent objects before changing the view, which otherwise may lead to run
time errors.

Context

You perform impact analysis at the view level. The tool helps to identify all dependent objects of a target
calculation view, one level at a time. This means that, for each of the dependent object, you can further
drilldown and identify the next level of dependent objects and until the leaf object.

SAP HANA Modeling Guide


178 PUBLIC Additional Functionality for Calculation Views
Procedure

1. Start SAP Web IDE in a Web browser.


2. In the Workspace view, select the required calculation view.

3. In the context menu, choose Modeling Actions Impact Analysis .


In a new tab, the tool opens an editor for impact analysis. You use this editor to identify all dependent
objects of the target calculation view. Use the collapse or expand button for each data source to view its
next level of dependent object.
4. In the new editor, expand the Properties section (at the bottom of the editor) to view additional details such
as the object type, object name, and more, for a selected object.

7.4 Performance Analysis

The SAP Web IDE supports opening a calculation view in performance analysis mode. The objective of the
performance analysis mode is to provide such information to users that helps them understand the
performance of the calculation view when it is executed.

When you open a calculation view in performance analysis mode, you obtain information on the catalog tables
modeled in the view. For example, information on table partitions, number of rows in the tables, and more.

The information that the tool displays in performance analysis mode depends on the view node that you select
and the data sources within this view node. In addition, opening a calculation view in performance analysis
mode also helps to:

Identify number of rows in a table

Identify those data sources that have number of rows above a certain threshold value. If you want to configure
the threshold value,

1. In the left sidebar, choose (Preferences).


2. Choose Modeler.
3. In the Threshold Value text field, provide the required threshold value.
4. Choose Save.

 Note

If the tables have rows more than the threshold value, the tool displays a warning icon across tables in the
view editor.

Identify Table Partitions and Table Types

If you have modeled a calculation view with partitioned tables, identify the partitioned tables and its partition
type (Hash, Range, Round Robin).

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 179
Related Information

Open Calculation Views in Performance Analysis Mode [page 180]


Debug Calculation Views [page 182]

7.4.1 Open Calculation Views in Performance Analysis Mode

When you open a calculation view in performance analysis mode, you obtain information on joins, join tables,
table partitions, table types, and other such information that to better understand the performance of
calculation views when it is executed.

Context

For example, the number of rows in a data source and table partitions impact the performance of your queries.
The performance analysis mode provides information on such details at design time. Based on this information
you can model more efficient calculation views and improve its performance when it is executed.

Procedure

1. Start SAP Web IDE in a Web browser.


2. Open the required calculation view in the view editor.
3. Select a view node that contains catalog tables.

 Note

You cannot analyze the performance of the Semantics node.

4. In the scenario pane toolbar, choose the (Performance analysis) icon to switch to the performance
analysis mode.
For the selected view node, the tool displays the following information in the Performance Analysis tab.
○ Join Details (if the selected view node is a join node.)
○ Data Source Details

 Note

When you are in performance analysis mode, you can switch to normal mode by choosing the same
icon in the toolbar. If you want to always open a calculation view in performance analysis mode as a
default, it is necessary to configure the preferences.

1. In the menu bar, choose (Preferences).

SAP HANA Modeling Guide


180 PUBLIC Additional Functionality for Calculation Views
2. Choose Modeler.
3. Select Always open Calculation Views in performance analysis mode.
4. Choose Save.

Related Information

Performance Analysis [page 179]


Join Details [page 181]
Data Source Details [page 181]

7.4.1.1 Join Details

Open a calculation view in performance analysis mode and select a join view node that has catalog tables as
data sources.

If you have defined a join for the catalog tables, then the JOIN DETAILS section in Performance Analysis tab
provides the following information:

● Catalog tables participating in the join. The tables include the left table and right table.
● The cardinality and join type that you have selected for each join.
● Information on whether you have maintained the referential integrity for the join table.
● If the cardinality that the tool proposes is different from the cardinality that you select or if you have not
maintained referential integrity, tool displays a warning.

 Note

Only users with SELECT privileges on the catalog tables participating in the join can view join validation
status.

 Restriction

The tool does not support performance analysis and debug queries for join view nodes with multi join
definitions.

7.4.1.2 Data Source Details

Open a calculation view in performance analysis mode and select a view node that has catalog tables as data
sources.

For a selected view node, the DATA SOURCE DETAILS section in Performance Analysis tab provides the
following information:

● The catalog tables available in a selected view node.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 181
● The catalog table type.
● If catalog table is partitioned, then tool provides details on the partition type (Hash, Range, Round Robin).
● Number of rows in the catalog table. Also, tool displays a warning icon for catalog tables with number of
rows more than the threshold value that you have defined.
● If you are using scale-out architecture with multiple nodes connected to an SAP HANA system, the tool
provides information on the table group name, and the table group type and its subtype.

 Note

Only users with system privilege INIFILE ADMIN can identify whether a system is using a scale-out
architecture.

7.4.2 Debug Calculation Views

For debugging calculation views, the graphical modeling tool in SAP Web IDE provides a debugger editor. Open
the calculation view in the debugger editor (in debug mode) by executing a debug query that the tool proposes
or by executing your own debug query.

Context

The debugging operation helps analyze the runtime behavior of a calculation view. Based on the analysis, you
can make necessary changes to the view at design time and improve its performance when it is executed. The
tool supports several debugging operations within the debugger editor. For example, write a SQL query for
debugging a calculation view and identify those attributes or data sources in the calculation view that the
engine consumes for executing the query, and also those objects that the engine does not consume.

Procedure

1. Open the required calculation view in the view editor.

2. In the view editor toolbar, choose (Debug this view).


3. Select the Semantics node.
4. Select the Debug Query tab.
The SQL editor in the Debug Query tab by default proposes a query. You can use this query to debug the
calculation view or use your own query in the SQL editor to debug the calculation view. At any point in time,

you can reset to the default query. Choose (Reset Query) to reset the query.

 Note

The tool proposes a query in the SQL editor after analyzing the existing version of your calculation view.
If you have changed the existing version, then ensure to build the calculation view before debugging.

SAP HANA Modeling Guide


182 PUBLIC Additional Functionality for Calculation Views
5. Start debugging.
Once you have identified the query to debug the calculation view, begin the debugging process.

a. In the SQL editor menu bar, choose (Execute) to start the debugging process.

Results

This operation opens the calculation view in the debugger editor in read-only mode. Use the debugger editor to
analyze the performance of your calculation view at runtime.

 Note

You can modify the calculation view only in the standard calculation view editor outside of the debug
session.

Related Information

Using the Debugger Editor [page 183]


Predefined Validation Rules [page 184]

7.4.2.1 Using the Debugger Editor

The debugger editor opens the calculation view in debug mode and helps in analyzing the runtime
performance of calculation views.

The data in the debugger editor largely depends on the query you execute to debug the calculation view. The
debugger editor provides the following information when you debug a selected calculation view.

Helps identify pruned and unpruned data sources in calculation views.

The debugger editor provides information on all pruned and unpruned data sources and columns. Pruned data
sources refer to those underlying calculation views that the engine does not require for executing the debug
query on the selected calculation view. Pruned data sources are greyed out in the debugger editor.

Similarly, pruned columns are those columns in a view node that the engine does not require or consume to
execute the debug query. Select the required view node and choose the Columns tab. The pruned columns are
greyed out.

Allows drilldown on underlying data sources for detailed analysis

You can drilldown any underlying data source (calculation view) and analyze its performance. For performing
the drilldown operation, in the debugger editor, select an underlying data source (calculation view) and choose

. This operation opens the selected underlying data source in a new debugger editor. You can perform
similar debugging operations on the underlying data source.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 183
Provides simple intermediate data preview

Select a view node in the debugger editor and choose the Debug Query tab. By default, the SQL editor in the

Debug Query tab displays the subquery relevant to the selected view node. Choose (Reset Query) to
preview the output of the selected view node.

Displays results of executing the performance validation rules on the calculation view.

The graphical modeling tool in SAP Web IDE contains predefined validation rules with the objective of validating
the performance of a calculation view. When you execute a debug query and open the calculation view in the
debugger editor, the tool also automatically executes these predefined validation rules. The tool displays the
results of the execution at the bottom of the debugger editor. Hover over the Warning icon for more details. If
you want the Warning icon to appear, then the execution must encounter any predefined violations.

7.4.2.2 Predefined Validation Rules

Executing the predefined validation rules helps identify specific design time factors that impact the
performance of calculation views.

The tool automatically executes the predefined validation rules when you execute the debug query. For
example, calculated columns or aggregated columns in filter expressions impact the performance of
calculation views. When you execute the validation rule, Calculation in filter expression, you can identify
whether you have modeled the calculation view with calculated columns or aggregated columns in filter
expressions. You can change your calculation views at design time respectively.

Predefined Validation Rule Objective

Calculation in filter expression rule Helps identify whether you have modeled the calculation view with calculated
columns or aggregated columns in filter expressions.

Calculation in joins rule Helps identify whether you have modeled the calculation view with calculated
columns or aggregated columns in join conditions.

Partition types in join rule Helps identify whether the tables participating the join are partition tables
and if the 1st level partition type of these two tables is different.

7.5 Maintain Comments for Calculation View Objects

When you are modeling a calculation view, you can also maintain comments for the view or for its objects such
as parameters, calculated columns, view nodes, and more. The comments can include, for example,

SAP HANA Modeling Guide


184 PUBLIC Additional Functionality for Calculation Views
information that provides more clarity on the calculation view or its objects for data modelers accessing the
same view or its objects.

Context

Maintaining comments help you store more information related to the calculation view or to store and provide
reference information for other data modelers working on the same calculation view. You can also use the
comments for documentation purposes.

● Columns in the semantics node


● View nodes
● Input parameters and variables
● Hierarchies
● Calculated columns and restricted columns in underlying view nodes

 Note

The tool does not support translating comments maintained for the calculation view or its objects.

Procedure

1. Start SAP Web IDE in a Web browser.


2. Open the required calculation view for which you want to maintain comments.
3. Maintain comments for the calculation view at the view level.
a. Select the Semantics node.

b. In the editor toolbar, choose (Expand Details Panel).


c. Choose the View Properties tab.
d. Choose General.
e. In the Notes text field, enter a new comment or edit any existing comment.
4. Maintain comments for columns in the semantics node.
a. Select the Semantics node.
b. Choose the Columns tab.
c. Select the column for which you want to maintain comments.

d. In the Notes column property, choose (Add Comment).

 Note

Configure default column properties.

If you do not see Notes column property, choose the (Customize Column Display) icon in the
menu bar and ensure that you have selected the Notes column property. Use the horizontal scroll
bar to view all the available column properties.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 185
e. Enter a new comment or edit an existing comment.
5. Maintain comments for view nodes.
a. Select the view node other than the Semantics node and the default view nodes.

b. Choose (Add Comment).


c. Enter a new comment or edit an existing comment.
6. Maintain comments for input parameters or variables.
a. Select the Semantics node.
b. Choose the Parameters tab.
c. Select an input parameter or variable for which you want to maintain comments.
d. In the Notes text field, enter a new comment or edit any existing comment.
7. Maintain comments for calculated columns or restricted columns.
a. Select the default view node.
b. Choose the Calculated Columns tab or Restricted Columns tab.
c. Select a calculated column or a restricted column for which you want to maintain comments.
d. In the Notes text field, enter a new comment or edit any existing comment.
8. Maintain comments for hierarchies.
a. Select the default view node.
b. Choose the Hierarchies tab.
c. Select the required hierarchy for which you want to maintain comments.
d. In the Notes text field, enter a new comment or edit any existing comment.

7.6 Replacing Nodes and Data Sources

Replace a view node with any of the other underlying view nodes or replace a data source in view node with
other available data sources in the catalog object.

The column view for complex calculation views may contain multiple levels of view nodes. If you manually
delete a node in column view (without using the replace view node feature) and add new node, you lose the
semantic information of the deleted node. However, if your requirement is to replace the deleted view node
with its underlying view node, then you can use the replace feature to replace the view node with its underlying
node and retain the semantic information of the changed node. Similarly, you can also replace a data source in
a view node with other available data sources in the catalog object.

Related Information

Replace a View Node in Calculation Views [page 187]


Replace a Data Source in Calculation Views [page 188]

SAP HANA Modeling Guide


186 PUBLIC Additional Functionality for Calculation Views
7.6.1 Replace a View Node in Calculation Views

Replace a view node in a calculation view with any of its underlying nodes without performing a delete
operation, and retain the semantic information of the changed node.

Context

For example, in the following calculation view, if you want to replace the node Union_1 with the node,
Projection_1, then you can do it by executing the following procedure.

Procedure

1. Open required calculation view in the view editor.


2. Select a node that you want to replace.
3. In the context menu, choose Replace With Node.
4. In the Select New Node dialog box, select a view node that you want use for replacing.
5. Manage the source and target mappings respectively.

 Note

It is necessary to delete all unmapped target columns and references.

6. If you want to remove the node from the column view, select the Delete the node after replace checkbox.

If you do not select this checkbox, the view node appears as an orphan node in the column view.
7. Choose Finish.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 187
7.6.2 Replace a Data Source in Calculation Views

Replace a data source in a calculation view with another data source in the catalog object without performing a
delete operation, and retain the semantic information of the changed node.

Context

For example, in the following calculation view, if you want to replace the data source, Projection_1 of Union_1
with another data source in the catalog object, then you can do it by executing the following procedure.

Procedure

1. Open required calculation view in the view editor.


2. Select a data source you want to replace.
3. In the context menu of the data source, choose Replace With Data Source.

 Restriction

You cannot replace a data source in a join view node that has more than two data sources.

4. In the Find Data Sources dialog box, enter the name of the new data source.
5. Select the data source from the list.
6. Choose Next.
7. Manage the source and target mappings.
8. Choose Finish.

SAP HANA Modeling Guide


188 PUBLIC Additional Functionality for Calculation Views
7.7 Using Functions in Expressions

This section describes the functions, which you can use in expressions of column engine language. You create
expressions, for example, while creating expressions for calculated attributes or calculated measures.

You can create expressions, for example in calculated columns using the column engine (CS) language or the
SQL language.

 Note

Related SAP Notes. The SAP Note 2252224 describes the differences between the CS and SQL string
expression with respect to Unicode or multibyte encoding. The SAP Note 1857202 describes the SQL
execution of calculation views.

Related Information

String Functions [page 189]


Conversion Functions [page 192]
Mathematical Functions [page 194]
Date Functions [page 194]
Miscellaneous Functions [page 199]
Using Functions in Expressions [page 189]
Spatial Functions [page 196]
Spatial Predicates [page 198]

7.7.1 Using Column Engine Functions

7.7.1.1 String Functions

String functions are scalar functions that perform an operation on a string input value and return a string or
numeric value.

Function Syntax Purpose

strlen int strlen(string) Returns the length of a string in bytes,


as an integer number.

midstr string midstr(string, int, int) Returns a part of the string starting at
arg2, arg3 bytes long.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 189
Function Syntax Purpose

arg2 is counted from 1 (not 0).

midstru string midstru(string, int) Returns a part of the string starting at


character or surrugate arg2, arg3
string midstru(string, int, int)
characters, or surrogates long.

leftstr string leftstr(string, int) Returns arg2 bytes from the left of the
arg1. If arg1 is shorter than the value of
arg2, the complete string is returned.

rightstr string rightstr(string, int) Returns arg2 bytes from the right of
the arg1. If arg1 is shorter than the
value of arg2, the complete string is
returned.

leftstru string leftstru(string, int) return arg2 characters from the left of
the string. If arg1 is shorter than arg2
characters, the complete string is
returned.

rightsru string rightstru(string, int) return arg2 characters from the right of
the string. If arg1 is shorter than arg2
characters, the complete string is
returned.

instr int instr(string, string) Returns the position of the first


occurrence of the second string within
the first string (>
= 1) or 0, if the second string is not
contained in the first.

instru int instru(string, string) return the character position of the


first occurrence of the second string
within the first string (>= 1) or 0, if the
second string is not contained in the
first. This assumes inputs to be
unicode expressed in utf-8, if the input
is not encoded this way, the result is
less meaningful.

hextoraw string hextoraw(string) Convert a hexadecimal representation


of bytes to a string of bytes. The
hexadecimal string may contain 0-9,
upper or lowercase a-f and no spaces
between the two digits of a byte;
spaces between bytes are allowed.

rawtohex string rawtohex(string) convert a string of bytes to its


hexadecimal representation.

SAP HANA Modeling Guide


190 PUBLIC Additional Functionality for Calculation Views
Function Syntax Purpose

The output contains only 0-9 and


(upper case) A-F, no spaces and is
twice as many bytes as the original
string.

ltrim string ltrim(string) removes a whitespace prefix from a


string. The Whitespace characters may
string ltrim(string, string) be specified in an optional argument.
This function operates on raw bytes of
the UTF8-string and has no knowledge
of multi byte codes (you may not
specify multi byte whitespace
characters).

rtrim string rtrim(string) removes trailing whitespace from a


string. The Whitespace characters may
string rtrim(string, string) be specified in an optional argument.
This function operates on raw bytes of
the UTF8-string and has no knowledge
of multi byte codes (you may not
specify multi byte whitespace
characters).

trim string trim(string) removes whitespace from the


beginning and end of a string. These
string trim(string, string) should be equivalent:

- trim(s) = ltrim(rtrim(s))

- trim(s1, s2) = ltrim(rtrim(s1, s2), s2)

lpad string lpad(string, int) add whitespace to the left of a string. A


second string argument specifies the
string lpad(string, int, string) whitespace, which is added repeatedly
until the string has reached the
intended length. If no second string
argument is specified, chr(32) (' ') gets
added. This function operated on
UTF-8 bytes and has no knowledge of
unicode characters (neither for the
whitespace string nor for length
computation).

rpad string rpad(string, int) add whitespace to the end of a string. A


second string argument specifies the
string rpad(string, int, string)
whitespace, which is added repeatedly
until the string has reached the
intended length. If no second string
argument is specified, chr(32) (' ') gets
added. This function operated on
UTF-8 bytes and has no knowledge of
unicode characters (neither for the
whitespace string nor for length
computation).

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 191
Function Syntax Purpose

replace string replace(string, string, string) replace every occurrence of arg2 in


arg1 with arg3 and return the resulting
string

upper string upper(string) return an all upper case version of the


string. Unlike most other string
functions, this also attempts to convert
unicode characters in CESU encoding
beside the usual a-z.

lower string lower(string) return an all lower case version of the


string. Unlike most other string
functions, this also attempts to convert
unicode characters in CESU encoding
beside the usual A-Z.

chars chars(string) return the number of characters in a


string. This returns the number of
characters in an UTF-8 encoded string.
In a CESU-8 encoded string, it returns
the number of 16-bit words of that
string if it were encoded if UTF-16.

charpos charpos(string, int) return the position of the nth character


in a string (n starting with 1). The string
is interpreted as UTF-8 as it is in the
preceding chars() function.

7.7.1.2 Conversion Functions

Data type conversion functions are used to convert arguments from one data type to another, or to test
whether a conversion is possible.

Function Syntax Purpose Example

int int int(arg) convert arg to int type int(2)

float float float(arg) convert arg to float type float(3.0)

double double double (arg) convert arg to double type double(3)

sdfloat sdfloat sdfloat (arg) convert arg to sdfloat type

decfloat decfloat decfloat (arg) convert arg to decfloat type

fixed fixed fixed (arg, int, int) arg2 and arg3 are the fixed(3.2, 8, 2) + fixed(2.3, 8,
intDigits and fractdigits 3)
parameters, respectively.
Convert arg to a fixed type of
either 8, 12, or 16 byte

SAP HANA Modeling Guide


192 PUBLIC Additional Functionality for Calculation Views
Function Syntax Purpose Example

length, depending on
intDigits and fractDigits

string string string (arg) convert arg to string type

raw raw raw (arg) convert arg to raw type

date date date(stringarg) convert arg to date type. The date(2009) -> date('2009')
first version parses a string
date date(fixedarg) in the format "yyyy-mm-dd date(2009, 1, 2) ->
hh:mi:ss" where trailing date('2009-01-02')
date date(int, int) components except for the
year may be omitted. The date(fixed(2000020313502
date date(int, int, int)
version with one fixed 6.1234567, 10, 4)) ->
date date(int, int, int, int) number arg strips digits date('2000-02-03 13:50:26')
behind the comma and tries
date date(int, int, int, int, int) to make a date from the rest.
The other versions accept
date date(int, int, int, int, int,
the individual components to
int)
be set.

longdate longdate longdate(stringarg) convert arg to longdate type, longdate(fixed(2000020313


similar to the preceding date
5026.1234567, 10, 5)) ->
longdate longdate(fixedarg) function.
longdate('2000-02-03
longdate longdate(int, int, 13:50:26.1234500')
int)
longdate(2011, 3, 16, 9, 48,
longdate longdate(int, int, 12, 1234567) ->
int, int, int) longdate('2011-03-16
09:48:12.1234567')
longdate longdate(int, int,
int, int, int, int)

longdate longdate(int, int,


int, int, int, int, int)

time time time(stringarg) convert arg to time type,


similar to the preceding date
time time(fixedarg) function

time time(int, int)

time time(int, int, int)

seconddate seconddate(string) Convert to seconddate. One


stringargs is a string with
seconddate(int, int, int, int, default parsing; two
int, int) stringargs is a format string
in the second arg, numeric
args are the date
components.

secondtime secondtime(string) Converto to secondtime.

secondtime(string, string)

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 193
Function Syntax Purpose Example

secondtime(int, int, int)

7.7.1.3 Mathematical Functions

Scalar math functions perform a calculation, based on input values that are provided as arguments, and return
a numeric value.

Function Syntax Purpose Example

sign int sign(double) Sign returns -1, 0 or 1


depending on the sign of its
int sign(time) argument. Sign is
implemented for all numeric
int sign(date) types, date, and time.

abs double abs(double) Abs returns arg, if arg is


positive or zero, -arg else.
decfloat abs(decfloat) Abs is implemented for all
numeric types and time.
decfloat abs(decfloat)

time abs(time)

round double round(double, int) Round does rounding of round(123.456, 0) = 123


absolute values toward zero
while the sign is retained round(123.456, 1) = 123.5

round(-123.456, 1) = -123.5

round(123.456, -1) = 120

rounddown double rounddown(double, Rounddown rounds toward rounddown(123.456, -1) =


int) negative infinity making
120
rounddown(-1.1, 0) = -2
rounddown(-123.456, -1) =
-130

7.7.1.4 Date Functions

Date and time functions are scalar functions that perform an operation on a date and time input value and
returns either a string, numeric, or date and time value.

Function Syntax Purpose

utctolocal utctolocal(datearg, timezonearg) Interprets datearg (a date, without


timezone) as utc and convert it to the

SAP HANA Modeling Guide


194 PUBLIC Additional Functionality for Calculation Views
Function Syntax Purpose

timezone named by timezonearg (a


string)

localtoutc localtoutc(datearg, timezonearg) Converts the local datetime datearg to


the timezone specified by the string
timezonearg, return as a date

weekday weekday(date) Returns the weekday as an integer in


the range 0..6, 0 is Monday.

now now() Returns the current date and time


(localtime of the server timezone) as
date

daysbetween daysbetween(date1, date2) Returns the number of days (integer)


between date1 and date2. The first
daysbetween(daydate1, daydate2)
version is an alternative to date2 -
daysbetween(seconddate1, date1.
seconddate2)
Instead of rounding or checking for
daysbetween(longdate1, longdate2) exactly 24 hours distance, this
truncates both date values today
precision and subtract the resulting
day numbers, meaning that if arg2 is
not the calendar day following arg1,
daysbetween returns 1 regardless of
the time components of arg1 and arg2.

secondsbetween secondsbetween(seconddate1, Returns the number of seconds the


seconddate2) first to the second arg, as a fixed point
number. The returned value is positive
secondsbetween(longdate1,
if the first argument is less than the
longdate2)
second. The return values are fixed18.0
in both cases (note that it may prove
more useful to use fixed11.7 in case of
longdate arguments).

component component(date, int) The int argument may be int the range
1..6, the values mean year, month, day,
hour, minute, second, respectively. If a
component is not set in the date, the
component function returns a default
value, 1 for the month or the day, 0 for
other components. You can also apply
the component function to longdate
and time types.

addseconds addseconds(date, int) Return a date plus a number of


seconds. Fractional seconds are used
addseconds(seconddate, decfloat) in case of longdate. If any argument is
null, then null handling is (in opposition
addseconds(longdate, decfloat) to the default done with adds) to return
null.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 195
Function Syntax Purpose

adddays adddays(date, int) Return a date plus a number of days. If


any argument is null, then null handling
adddays(daydate, int)
is (in opposition to the default done
adddays(seconddate, int) with adds) to return null.

adddays(longdate, int)

quarter quarter(date) Return a string 'yyyy-Qn', yyyy being


the year of the quarter and n the
quarter(date, month) quarter of the year. An optional start
month (of the fiscal year) may be
supplied. For example,
quarter(date('2011-01-01'), 6) is '2010-
Q3' and quarter(date('2011-06-01'), 6)
is '2011-Q1'.

format format(longdate, string) Date values may be used together with


format strings, as described elsewhere
in the NewDb documentation (look for
descriptions of the TO_DATE and
TO_CHAR SQL functions) . For
example, format(longdate('2011-06-09
20:20:13.1234567'), 'YYYY/MM/
DD"T"HH24:MI:SS.FF7')

7.7.1.5 Spatial Functions

The following table lists the supported spatial functions for expressions in the column engine language.

Function Type Description

ST_Area ST_MultiPolygon Computes the area of the multipolygon.

ST_Area ST_Polygon Calculates the area of a polygon.

ST_AsGeoJSON ST_Geometry Returns a string representing a geometry in JSON format.

ST_AsText ST_Geometry Returns the text representation of a ST_Geometry value.

ST_Buffer ST_Geometry Returns the ST_Geometry value that represents all points whose dis­
tance from any point of a ST_Geometry value is less than or equal to a
specified distance in the given units.

ST_ConvexHull ST_Geometry Returns the convex hull of the geometry value.

ST_Difference ST_Geometry Returns the geometry value that represents the point set difference of
two geometries.

ST_Distance ST_Geometry Returns the distance between two geometries in the given unit, ignor­
ing z- and m-coordinates in the calculations.

SAP HANA Modeling Guide


196 PUBLIC Additional Functionality for Calculation Views
Function Type Description

ST_Envelope ST_Geometry Returns the bounding rectangle for the geometry value.

ST_GeomFromText ST_Geometry Constructs a geometry from a character string representation.

ST_GeometryType ST_Geometry Returns the name of the type of the ST_Geometry value.

ST_Intersection ST_Geometry Returns the geometry value that represents the point set intersection
of two geometries.

ST_IsEmpty ST_Geometry Determines whether the geometry value represents an empty set.

ST_SRID ST_Geometry Retrieves or modifies the spatial reference system associated with the
geometry value.

ST_SRID(INT) ST_Geometry Changes the spatial reference system associated with the geometry
without modifying any of the values.

ST_SymDifference ST_Geometry Returns the geometry value that represents the point set symmetric
difference of two geometries.

ST_Transform ST_Geometry Creates a copy of the geometry value transformed into the specified
spatial reference system.

ST_Union ST_Geometry Returns the geometry value that represents the point set union of two
geometries.

The preceding functions are categorized based on the use case as shown:

Geometry Construction Functions

● ST_Geometry ST_GeomFromText(String/Clob wkt, Int srid);

Geometry Serialization

● String/Clob ST_AsText(ST_Geometry geometry);


● String/Clob ST_AsGeoJson(ST_Geometry geometry);

Geometry Transformation

● ST_Geometry ST_Transform(ST_Geometry geometry, Int srid);

Geometry Inspection

● String ST_GeometryType(ST_Geometry geometry);


● Int ST_SRID(ST_Geometry geometry);
● Int ST_IsEmpty(ST_Geometry geometry);
● ST_Geometry ST_Envelope(ST_Geometry geometry);

Calculations on a Single Geometry

● Double ST_Area(ST_Geometry geometry);


● ST_Geometry ST_ConvexHull(ST_Geometry geometry);
● ST_Geometry ST_Buffer(ST_Geometry geometry, Double buffer [, String uom]);

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 197
Calculations on Two Geometries

● Double ST_Distance(ST_Geometry geometry1,


● ST_Geometry geometry2 [, String uom]);
● ST_Geometry ST_Intersection(ST_Geometry geometry1, ST_Geometry geometry2);
● ST_Geometry ST_Union(ST_Geometry geometry1, ST_Geometry geometry2);
● ST_Geometry ST_Difference(ST_Geometry geometry1, ST_Geometry geometry2);
● ST_Geometry ST_SymDifference(ST_Geometry geometry1, ST_Geometry geometry2);

7.7.1.6 Spatial Predicates

The following table lists the supported spatial predicates for expressions in the column engine language.

Predicate Type Description

ST_Contains ST_Geometry Tests if a geometry value spatially con­


tains another geometry value.

ST_CoveredBy ST_Geometry Tests if a geometry value is spatially


covered by another geometry value.

ST_Covers ST_Geometry Tests if a geometry value spatially cov­


ers another geometry value.

ST_Crosses ST_Geometry Tests if a geometry value crosses an­


other geometry value.

ST_Disjoint ST_Geometry Test if a geometry value is spatially dis­


joint from another value.

ST_Equals ST_Geometry Tests if a ST_Geometry value is spatially


equal to another ST_Geometry value.

ST_Intersects ST_Geometry Test if a geometry value spatially inter­


sects another value.

ST_Overlaps ST_Geometry Tests if a geometry value overlaps an­


other geometry value.

ST_Touches ST_Geometry Tests if a geometry value spatially


touches another geometry value.

ST_Within ST_Geometry Tests if a geometry value is spatially


contained within another geometry
value.

ST_WithinDistance ST_Geometry Test if two geometries are within a


specified distance of each other.

SAP HANA Modeling Guide


198 PUBLIC Additional Functionality for Calculation Views
7.7.1.7 Miscellaneous Functions

The following table lists the miscellaneous functions that you can use while creating expressions.

Function Syntax Purpose Example

if if(intarg, arg2, arg3) return arg2 if intarg is if("NETWR"<=500000,'A',


considered true (not equal to if("NETWR"<=1000000,'B','
zero), else return arg3. C') )
Currently, no shortcut
evaluation is implemented,
meaning that both arg2 and
arg3 are evaluated in any
case. This means that you
cannot use if to avoid a
divide by zero error, which
has the side effect of
terminating expression
evaluation when it occurs.

jf if(intarg, arg2, arg3) The function jf behaves


similar to if, only with SQL
semantic. While if returns
NULL if the predicate (first
argument) is NULL
(undefined), jf uses the else-
value (arg3) in that case.

in in(arg1, ...) return 1 (= true) if arg1 is


equal to any of the remaining
args, return 0 else

case case(arg1, default) return value1 if arg1 == case("CATEGORY", 'A', 'LV',


case(arg1, cmp1, value1, cmp1, value2 if arg1 == 'B', 'MV', 'HV')
cmp2, value2, ..., default) cmp2, and more, default if
there no match

box The function box behaves


similar to case, only with
SQL semantic. While case
returns NULL if arg1 is NULL,
box returns the default in
that case.

isnull isnull(arg1) return 1 (= true), if arg1 is set


to null and null checking is
on during Evaluator run
(EVALUATOR_MAY_RETURN
_NULL)

max max(arg1, arg2, arg3, ...) return the maximum value of max(0, 5, 3, 1)
the passed arguments list.
An arbitrary number of
arguments is allowed.
Arguments must be at least

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 199
Function Syntax Purpose Example

convertible into a common


type.

min min(arg1, arg2, arg3, ...) return the minimum value of min(1, 2, 3, 4)
the passed arguments list.
An arbitrary number of
arguments is allowed.
Arguments must be at least
convertible into a common
type.

sqladd sqladd(arg1, arg2) sqladd behaves like the sqladd(if("VAL_B" = 0,


operator '+', with NULL int(null), "VAL_C") /
handling changed to SQL "VAL_B", -1)
standard. While the operator
'+' returns the other
argument when one
argument is NULL, sqladd
returns NULL if any of its
arguments is NULL.

7.7.2 Using SQL Functions

7.7.2.1 Conversion Functions

Data type conversion functions convert data from one data type to another data type.

Data type conversion functions are used to convert function arguments from one data type to another, or to
test whether a conversion is possible.

 Note

In both implicit and explicit numeric type conversions, these functions always truncate the least significant
digits toward zero.

Function Syntax Purpose

TO_ALPHNUM TO_ALPHANUM (<value>) Converts a given <value> to an


ALPHANUM data type.

TO_BIGINT TO_BIGINT (<value>) If the input <value> has a mantissa,


then these digits are truncated during
the conversion process.

TO_BINARY TO_BINARY (<value>) Converts a <value> to a BINARY data


type. TO_BINARY (<value>)

SAP HANA Modeling Guide


200 PUBLIC Additional Functionality for Calculation Views
Function Syntax Purpose

TO_BLOB TO_BLOB (<value>) Converts a <value> to a BINARY data


type.

TO_CHAR TO_CHAR (value) Converts character data from any


supported character set into the CHAR
character set for the database.

TO_CLOB TO_CLOB (<value>) Converts a <value> to a CLOB data


type.

TO_DATE TO_BINARY (TO_DATE (<d> [, Converts the date string <d> into a
<format>]) DATE data type. If the <format>
specifier is omitted, the conversion is
performed using the date format
model.

TO_DATS TO_DATS (<d>) Converts the date string <d> into an


ABAP DATE string with format
'YYYYMMDD'.

TO_DECIMAL TO_DECIMAL (<value> [, <precision>, If <precision> and <scale> are not


<scale>]) specified, then DECIMAL becomes a
floating-point decimal number. In this
case, <precision> and <scale> can vary
within the range described above: 1-34
for <precision> and -6,111-6,176 for
<scale> depending on the stored value.
Unnecessary least significant digits in
the mantissa of the input value are
truncated during the conversion
process.

TO_DOUBLE TO_DOUBLE (<value>) Converts a specified <value> to a


DOUBLE (double precision) data type.

TO_FIXEDCHAR TO_FIXEDCHAR (<string>, <size>) Converts the specified <string> to a


CHAR value of fixed size as specified by
<size>, starting at the first character.
<size> cannot be a variable.

TO_INT TO_INT (<value>) If the input <value> has a mantissa,


then the mantissa is truncated during
the conversion process.

TO_INTEGER TO_INTEGER (<value>) Converts the <value> to an INTEGER


data type.If the input <value> has a
mantissa, then these digits are
truncated during the conversion
process.

TO_NCHAR TO_NCHAR( string-expression [, The TO_NCHAR function converts a


source-charset-name ] ) TEXT expression, date, or number to
NTEXT in a specified format. This
function is typically used to format
output data.

TO_NCLOB TO_NCLOB (<value>) Converts a <value> to an NCLOB data


type.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 201
Function Syntax Purpose

TO_NUMBER TO_NUMBER(value) TO_NUMBER converts expression to a


value of NUMBER datatype.

TO_NVARCHAR TO_NVARCHAR (<value> [, <format>]) If the <format> specifier is omitted,


then the conversion is performed using
the date format model. The following
data types can be converted to
NVARCHAR using the TO_NVARCHAR
function: ALPHANUM, BIGINT, DATE,
DECIMAL, DOUBLE, FIXED12, FIXED16,
FIXED8, INTEGER, REAL,
SECONDDATE, SMALLDECIMAL,
SMALLINT, TIME, TIMESTAMP,
TINYINT, VARBINARY, VARCHAR,
CLOB, NCLOB, TEXT (if the value is
longer than the maximum length of
NVARCHAR, then an exception is
thrown)

TO_REAL TO_REAL (<value>) Converts a <value> to a REAL (single


precision) data type.

TO_SECONDDATE TO_SECONDDATE (<d> [, <format>]) If the <format> specifier is omitted,


then the conversion is performed using
the date format model.

TO_TIME TO_TIME (<t> [, <format>]) Converts time string <t> to the TIME
data type. If the <format> specifier is
omitted, then the conversion is
performed using the time format
model.

TO_TIME TO_TIME (<t> [, <format>]) Converts time string <t> to the TIME
data type. If the <format> specifier is
omitted, then the conversion is
performed using the time format
model.

TO_TIMESTAMP TO_TIMESTAMP (<d> [, <format>]) Converts date string <d> to the


TIMESTAMP data type. If the <format>
specifier is omitted, then the
conversion is performed using the date
format model.

TO_VARBINARY TO_VARCHAR (<value>) function returns a VARBINARY


(varying-length binary string)
representation of a string of any data
type.

TO_VARCHAR TO_VARCHAR (<value> [, <format>]) If the <format> specifier is omitted,


then the conversion is performed using
the date format model.

SAP HANA Modeling Guide


202 PUBLIC Additional Functionality for Calculation Views
7.7.2.2 String Functions

String functions perform extraction and manipulation on strings, or return information about strings.

Function Syntax Purpose

ABAP_LOWER ABAP_LOWER ( string ) Converts all characters in the <string>


parameter to lowercase.

ABAP_ALPHANUM ABAP_ALPHANUM ( <string>, The input value, <string>, is checked to


<chars> ) find out if it is numeric or a mixture of
numeric and non-numeric. If <string>
is numeric, then it is left-padded with
zeroes up to the length specified by
<chars>, if necessary. If <string> is a
mixture or numeric and non-numeric,
or is empty, then it is returned
unchanged. Strings that start with
spaces and contain only digits after the
whitespace prefix are regarded as
numeric.

ABAP_NUMC ABAP_NUMC ( <arg1>, <chars> ) String and numeric values are left-
padded with 0s if <arg1> is shorter
than <chars>. If <arg1> is longer than
<chars>, then characters are truncated
from the left. Numeric values are
rounded to their integer part and the
sign is discarded.LONGDATE,
SECONDDATE, DAYDATE, and
SECONDTIME values are padded and
truncated from the right side, as
necessary. SDFLOAT inputs are never
truncated but create an overflow error
if they are found to be too long.

ABAP_UPPER ABAP_UPPER ( string ) Converts all characters in the <string>


parameter to uppercase.

BINTONHEX BINTONHEX ( <expression> ) Converts a binary value to a


hexadecimal value as an NVARCHAR
data type. The input value is converted
to a binary value first if it is not a binary
value.

BINTOSTR BINTOSTR (<bstring>) Converts a VARBINARY string


<bstring> to a character string with
CESU-8 encoding.

CONCAT CONCAT (<str1>, <str2>) Returns a combined string consisting


of <string1> followed by <string2>. The
concatenation operator (||) is identical
to this function. The maximum length
of the concatenated string is
8,388,607. If the string length is longer
than the maximum length, an
exception is thrown. Exceptionally, an
implicit truncation is performed when

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 203
Function Syntax Purpose

converting an (N)CLOB typed value


with a size greater than the maximum
length of an (N)VARCHAR typed value.

CONCAT_NAZ CONCAT_NAZ ( <str1>, <str2> ) Returns a combined, non-null value


string consisting of <str1> followed by
<str2>. The maximum length of the
concatenated string is 8,388,607. If the
string length is longer than the
maximum length, then an exception is
thrown. Exceptionally, an implicit
truncation is performed when
converting an (N)CLOB typed value
with a size greater than the maximum
length of an (N)VARCHAR typed value.

LEFT LEFT(string, n) Returns the first <n> characters/bytes


from the beginning of <string>.Returns
an empty string value if <n> is less
than 1.Returns <string> (without blank
padding) if the value of <n> is greater
than the length of <string>.

LENGTH LENGTH(str) Returns the number of characters in


string <str>. If <str> is a VARCHAR,
then the function does not return the
number of bytes. In this case, the
number of characters like NVARCHAR-
typed strings are returned instead.
Supplementary plane Unicode
characters, each of which occupies 6
bytes in CESU-8 encoding, are counted
as two characters.

LIKE_REGEXPR <regex_subject_string> This predicate performs regular


LIKE_REGEXPR <pattern> [ FLAG expression matching. If any of the
<flag> ] following parameters is NULL:
<pattern>, <flag> or
<regex_subject_string>, then the
predicate returns FALSE.

LOCATE LOCATE (<haystack>, <needle>, Returns the position of a substring


<start_position>, <occurrences>) <needle> within a string
<haystack>.Returns 0 if <needle> is
not found within <haystack>, or if
<occurrences> is set to less than 1.
Returns NULL if <haystack> or
<needle> is NULL. If <start_position>
is not specified or is 0, then the search
starts at the beginning of the string
<haystack>. If <start_position> is
negative, then the search starts at the
ending of the string <haystack>. If
<occurrences> is not specified, then
the first matched position will be
returned.

SAP HANA Modeling Guide


204 PUBLIC Additional Functionality for Calculation Views
Function Syntax Purpose

LOCATE_REGEXPR LOCATE_REGEXPR([ <regex_position_ Searches a string for a regular


start_or_after> ] <pattern> [ FLAG expression pattern and returns an
<flag> ] IN <regex_subject_string> integer indicating the beginning
[ FROM <start_position> ] position, or the ending position plus 1,
[ OCCURRENCE <regex_occurrence> ] of one occurrence of the matched
[ GROUP <regex_capture_group> ] ) substring. If any of the following
parameters is NULL: <pattern>,
<flag>, <regex_subject_string>, ,
<start_position>, <regex_occurrence>
or <regex_capture_group>, then the
function returns NULL.

LOWER LOWER(string) Return an all lower case version of the


string. Unlike most other string
functions, this also attempts to convert
unicode characters in CESU encoding
beside the usual A-Z.

LPAD LPAD (<str>, <n> [, <pattern>]) Left-pads the end of <str> with spaces
to make a string of <n> characters. If
<pattern> is specified, then<str> is
padded using sequences of the given
characters until the required length is
met.

If the length of <str> is greater than


<n>, then no padding is performed and
the resulting value is truncated from
the right side to the length specified in
<n>.

LPAD returns an empty string value if


<n> is less than 1.

LTRIM LTRIM (<str> [, <remove_set>]) Returns string <str>, trimmed of all


leading spaces. If <remove_set> is
specified, LTRIM removes all the
characters contained in this set from
the start of string <str>. This process
continues until a character that is not
in <remove_set> is reached.

<remove_set> is treated as a set of


characters and not as a search string.

OCCURRENCES_REGEXPR OCCURRENCES_REGEXPR( <pattern> Returns the number of matches of a


[ FLAG <flag> ] IN regular expression search within a
<regex_subject_string> [ FROM string.
<start_position> ] )

REPLACE REPLACE(originalString, searchString, Searches in <original_string> for all


replaceString))
occurrences of <search_string> and
replaces them with<replace_string>.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 205
Function Syntax Purpose

● If two overlapping substrings


match the <search_string> in the
<original_string>, then only the
first occurrence is replaced.
● If <original_string> does not
contain an occurrence of
<search_string>, then
<original_string> is returned
unchanged.
● If <original_string>,
<search_string>, or
<replace_string> are NULL, then
NULL is returned.

REPLACE_REGEXPR REPLACE_REGEXPR (<pattern> Searches a string for a regular


[ FLAG <flag> ] IN expression pattern and returns the
<regex_subject_string> [ WITH string with either one or every
<replacement_string> ] [ FROM occurrence of the regular expression
<start_position> ] [ OCCURRENCE pattern that is replaced using a
<regex_replace_occurrence> ]) replacement string. If any of the
following parameters is NULL, then the
function returns NULL: <pattern>,
<flag>, <regex subject_string>,
<replacement_string>,
<start_position> or
<regex_replace_occurrence>.

RIGHT RIGHT(<str>, <n>) Returns the rightmost <n> characters/


bytes of string <str>. Returns an empty
string value if <n> is less than 1.
Returns string <str> (without blank
padding) if the value of <n> is greater
than the length of string <str>.

RPAD RPAD (<str>, <n> [, <pattern>]) Right-pads the end of <str> with
spaces or characters to make a string
of <n> characters in length. If
<pattern> is specified, then <str> is
padded using sequences of the given
characters until the required length is
met.

If the length of <str> is greater than


<n>, then no padding is performed and
the resulting value is truncated to the
length specified in <n>.

RPAD returns an empty string value if


<n> is less than 1.

SAP HANA Modeling Guide


206 PUBLIC Additional Functionality for Calculation Views
Function Syntax Purpose

RTRIM RTRIM (<str> [,<remove_set> ]) Returns a string trimmed of all trailing


spaces. If <remove_set> is specified,
then RTRIM removes all the characters
contained in the specified set from the
end of the string. This process
continues until a character that is not
in the <remove_set> has been reached.

<remove_set> is treated as a set of


characters and not as a search string.

SUBSTR_AFTER SUBSTR_AFTER (<str>, <pattern>) Returns a substring from the specified


string that follows the first occurrence
of the specified pattern. If <str> does
not contain the <pattern> substring,
then an empty string is returned. If
<pattern> is an empty string, then
<str> is returned. If <str> or <pattern>
is NULL, then NULL is returned.

SUBSTR_BEFORE SUBSTR_BEFORE (<str>, <pattern>) Returns a substring from the specified


string before the first occurrence of the
specified pattern.If <str> does not
contain the <pattern> substring, then
an empty string is returned.If
<pattern> is an empty string, then
<str> is returned.If <str> or <pattern>
is NULL, then NULL is returned.

SUBSTR <str>, <start_position> [, Returns a substring from the specified


<string_length>]
string starting from <start_position>
within the string. SUBSTRING can
return the remaining part of a string
from the <start_position>, or
optionally, a number of characters set
by the <string_length> parameter.

● If <start_position> is less than 1,


then it is considered to be 1.
● If <string_length> is less than 1,
then an empty string is returned.
● If <string_length> is greater than
the length of remaining part of
<str>, then the remaining part is
returned without blank padding.
● When used on binary types,
SUBSTRING factors in byte length
and interprets the offsets,
<start_position>and
<string_length>, as byte positions.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 207
Function Syntax Purpose

TRIM TRIM(string) Returns a string after removing leading


and trailing spaces.

UCASE UCASE(string) Converts all characters in string <str>


to uppercase. The UCASE function is
identical to the UPPER function.

UPPER UPPER(string) return an all upper case version of the


string. Unlike most other string
functions, this also attempts to convert
unicode characters in CESU encoding
beside the usual a-z.

CAST CAST (expression AS Returns the value of an expression


data_type(length)) converted to a supplied data type.

7.7.2.3 Mathematical Functions

Numeric functions perform mathematical operations on numerical data types or return numeric information.

Mathematical functions take numeric values, or strings with numeric characters, as inputs and return numeric
values. When strings with numeric characters are provided as inputs, implicit conversion from a string to a
number is performed automatically before results are computed.

Function Syntax Purpose

ABS ABS(numericArg) Returns the absolute value of a


numeric argument.

ACOS ACOS(numericArg) Returns the arc-cosine, in radians, of


<numericArg> between -1 and 1.

ASIN ASIN(numericArg) Returns the arc-sine, in radians, of the


<numericArg> between -1 and 1.

ATAN ATAN(numericArg) Returns the arc-tangent, in radians, of


the <numericArg>. The range of
<numericArg> is unlimited.

ATAN2 ATAN2 (<number1>, <number2>) Returns the arc-tangent, in radians, of


the ratio of two
numbers <number1> and <number2>.

BINTOHEX BINTOHEX(<expression>) Converts a binary value to a


hexadecimal value as a VARCHAR data
type. If the input value is not a binary
value, then it is first converted to a
binary value.

BITAND BITAND(nonNegativeArg, Performs an AND operation on the bits


nonNegativeArg) of the arguments <n> and <m>. The
BITAND function returns a result along
the argument's type.

SAP HANA Modeling Guide


208 PUBLIC Additional Functionality for Calculation Views
Function Syntax Purpose

BITCOUNT BITCOUNT(expression) Counts the number of set bits of the


argument <expression>. The
BITCOUNT function returns an
INTEGER value.

BITNOT BITNOT(expression) Performs a bitwise NOT operation on


the bits of the argument <expression>.
The BITNOT function returns a result
along the argument's type.

BITOR BITOR(expression1, expression2) This function performs an OR


operation on the bits of the arguments
<expression1> and <expression2>. The
BITOR function returns a result along
the argument's type.

BITXOR BITXOR(expression1, expression2) Performs an XOR operation on the bits


of the arguments <expression1> and
<expression2>. The BITXOR function
returns a result along the argument's
type.

CEIL CEIL(numericArg) Returns the first integer that is greater


than or equal to the value of
<numericArg>.

COS COS(numericArg) Returns the cosine of the angle


<numericArg>, in radians.

COSH COSH(numericArg) Computes the hyperbolic cosine of the


<numericArg>.

COT COT(numericArg) Computes the cotangent of a number


<numericArg>, where <numericArg> is
an angle expressed in radians.

EXP EXP(numericArg) Returns the result of the base of the


natural logarithms e raised to the
power of the argument <numericArg>.

FLOOR FLOOR(numericArg) Returns the largest integer that is not


greater than the numeric argument
<numericArg>.

HEXTOBIN HEXTOBIN(hexadecimalValue) HEXTOBIN returns a VARBINARY value


where each byte of the result
corresponds to two characters of
<hexadecimalValue>. If
<hexadecimalValue> does not contain
an even number of digits, an error is
returned. In SAP HANA, lowercase
characters in <hexadecimalValue> are
supported and are treated as
uppercase.

LN LN(numericArg) Returns the natural logarithm of the


numeric argument <numericArg>.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 209
Function Syntax Purpose

LOG LOG(base, numericArg) Returns the natural logarithm of a


number <numericArg> base <base>,
where <base> must be a positive value
greater than 1, and <numericArg>
must be any positive value.

MOD MOD(numericArg, divisor) Returns the remainder of a number


<numericArg> divided by a divisor
<divisor>.When <numericArg> is
negative, this function acts differently
to the standard computational modulo
operation. The following list shows
examples of what the MOD function
returns as the result: If <divisor> is
zero, then <numericArg> is returned.If
<numericArg> is greater than 0 and
<numericArg> is less than <divisor>,
then <numericArg> is returned.If
<numericArg> is less than 0 and
<numericArg> is greater than
<divisor>, then <numericArg> is
returned.In cases other than those
mentioned above, the remainder of the
absolute value of <numericArg>
divided by the absolute value of
<divisor> is used to calculate the
remainder. If <numericArg> is less than
0, then the returned remainder from
MOD is a negative number, and if
<numericArg> is greater than 0, then
the returned remainder from MOD is a
positive number.

POWER POWER(numericArg, exponent) Calculates <numericArg> raised to the


power of <exponent>.

ROUND ROUND (<n> [, <pos> [, Rounds argument <n> to the specified


amount of places (<pos>) after the
<rounding_mode>]])
decimal point. By default, the
value <n> is rounded up to the next
round figure. If the value is precisely in
halfway between two rounded values, it
is rounded up away from zero
(commercial rounding).

SIGN SIGN(numericArg) Returns 1 if <numericArg> is a positive


value, -1 if <numericArg> is a negative
value, 0 if <n> is equal to zero, and
NULL if <numericArg> is equal to
NULL.

SIN SIN(numericArg) Returns the sine of <numericArg>,


where <numericArg> is an angle
expressed in radians.

SAP HANA Modeling Guide


210 PUBLIC Additional Functionality for Calculation Views
Function Syntax Purpose

SINH SINH(numericArg) Returns the hyperbolic sine of


<numericArg>, where the argument is
an angle expressed in radians.

SQRT SQRT(numericArg) Returns the square root of the numeric


argument <numericArg>.

TAN TAN(numericArg) Returns the tangent of <numericArg>,


where <numericArg> is an angle
expressed in radians.

UMINUS UMINUS(numericArg) Returns the negated value of the


specified numeric argument
<numericArg>.

7.7.2.4 Date Functions

Date and time functions perform operations on date and time data types or return date or time information.

Function Syntax Purpose

ADD_DAYS ADD_DAYS(date,days) Computes the specified date plus the


specified number of days.

ADD_MONTH ADD_MONTHS(date, months) Computes the specified date plus the


specified number of months. To com­
pute the date so that the output date is
set to the last day of the month when
the input date is the last day of the
month, use the ADD_MONTHS_LAST
function. The parameter <date> must
be implicitly or explicitly converted to
one of the following SQL data
types:DATE, TIMESTAMP, SECOND­
DATE. The SQL data type of the output
parameters is the same as the SQL
data type of the input parameters. For
example, ADD_MONTHS_LAST(DATE)
returns a date, while
ADD_MONTHS_LAST(TIMESTAMP) re­
turns a timestamp.

ADD_MONTHS_LAST ADD_MONTHS_LAST(date, months) Computes the specified date plus the


specified number of months. If the in­
put date is the last day of the input
month, then the output date is set to
the last day of the output month.

ADD_SECONDS ADD_SECONDS(time, seconds) Computes the specified time plus the


number of specified seconds.

ADD_YEARS ADD_YEARS(date, years) Computes the specified date plus the


specified number of years.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 211
Function Syntax Purpose

CURRENT_DATE CURRENT_DATE Returns the current local system date.


Use UTC times instead of local time­
stamps. The use of local times or con­
version between local time zones can
require additional handling in applica­
tion code.

CURRENT_TIME CURRENT_TIME Returns the current local system time.


Use UTC times instead of local time­
stamps. The use of local times or con­
version between local time zones might
require additional handling in the appli­
cation code.

CURRENT_TIMESTAMP CURRENT_TIMESTAMP Returns the current local system time­


stamp information.Use UTC times in­
stead of local timestamps. The use of
local times or conversion between local
time zones might require additional
handling in the application code.

CURRENT_UTCDATE CURRENT_UTCDATE Returns the current UTC date.

CURRENT_UTCTIME CURRENT_UTCTIME Returns the current UTC time.

CURRENT_UTCTIMESTAMP CURRENT_UTCTIMESTAMP Returns the current UTC timestamp.

DAYNAME DAYNAME(date) Returns the weekday in English for


<date>.

DAYOFYEAR DAYOFYEAR(date) Returns an integer representation of


the day of the year for <date>.

DAYS_BETWEEN DAYS_BETWEEN(date1, date2) Computes the number of days between


<date1> and <date2>.

EXTRACT EXTRACT(part from date) Finds and returns the value of a speci­
fied datetime field from a specified
date.

EXTRACT_DAY EXTRACT_DAY(date) Finds and returns the value of a speci­


fied date field from a specified date.

EXTRACT_HOUR EXTRACT_HOUR(time) Finds and returns the value of a speci­


fied hour field from a specified date.

EXTRACT_MINUTE EXTRACT_MINUTE(time) Finds and returns the value of a speci­


fied minute field from a specified date.

EXTRACT_MONTH EXTRACT_MONTH(date) Finds and returns the value of a speci­


fied month field from a specified date.

EXTRACT_SECOND EXTRACT_SECOND(time) Finds and returns the value of a speci­


fied second field from a specified date.

EXTRACT_YEAR EXTRACT_YEAR(date) Finds and returns the value of a speci­


fied year field from a specified date.

SAP HANA Modeling Guide


212 PUBLIC Additional Functionality for Calculation Views
Function Syntax Purpose

ISOWEEK ISOWEEK(date) Returns the ISO year and week num­


bers of date <date>. The week number
is prefixed by the letter W. Both the
WEEK and ISOWEEK functions return
the week number for a specified date
but the format of the result is quite dif­
ferent, and the two functions may han­
dle the first week of the new year differ-
ently. For example, when supplied the
date 2017-01-01, the WEEK function
considers the date to be part of the first
week of 2017 and returns 1, whereas
ISOWEEK considers the date to be part
of the last week of 2016 and returns
2016-W52. ISOWEEK has either 52 or
53 full weeks, with the extra week con­
sidered to be a leap week

LAST_DAY LAST_DAY(date) Returns the date of the last day of the


month that contains the <date>.

LOCALTOUTC LOCALTOUTC(time, timezone) Interprets <time> (a time, without time­


zone) as utc and convert it to the time­
zone named by <timezone> (a string)

MONTH MONTH(date) Returns the number of the month from


<date>.

MONTHNAME MONTHNAME(date) Returns the name of the month for


<date>.

MONTHS_BETWEEN MONTHS_BETWEEN(date1, date2) Computes the number of months be­


tween <date1> and <date2>. Returns
NULL if either of <date1> or <date2> is
NULL.

NANO100_BETWEEN NANO100_BETWEEN(date1, date2) Computes the time difference between


date arguments <date1> and <date2>,
to the precision of 0.1 microseconds.

NOW NOW() Returns the current date and time (lo­


caltime of the server timezone) as date

QUARTER QUARTER(date) Return a string 'yyyy-Qn', yyyy being


the year of the quarter and n the quar­
ter of the year. An optional start month
(of the fiscal year) may be supplied. For
example, quarter(date('2011-01-01'), 6)
is '2010-Q3' and quar­
ter(date('2011-06-01'), 6) is '2011-Q1'.

SECOND SECOND(time) Returns a value of seconds for a given


time. Subseconds are included for
TIMESTAMP datatypes.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 213
Function Syntax Purpose

SECONDS_BETWEEN SECONDS_BETWEEN(date1, date2) Computes the number of seconds be­


tween date arguments <date1> and
<date2>, which is semantically equal to
(<date2> - <date1>).

UTCTOLOCAL UTCTOLOCAL(time, timezone) Interprets datearg (a date, without


timezone) as utc and convert it to the
timezone named by timezonearg (a
string)

WEEK WEEK(date) Returns the week number of the year as


an integer. Weeks start Monday and end
Sunday. The first days of the year up to
the first Sunday are week 1; the seven
days that begin with the day after the
first Sunday are week 2, and so on.
Both the WEEK and ISOWEEK functions
return the week number for a specified
date but the format of the result is quite
different, and the two functions may
handle the first week of the new year
differently. For example, when supplied
the date 2017-01-01, the WEEK function
considers the date to be part of the first
week of 2017 and returns 1, whereas
ISOWEEK considers the date to be part
of the last week of 2016 and returns
2016-W52.

WEEKDAY WEEKDAY(date) Returns the weekday as an integer in


the range 0..6, 0 is Monday.

YEAR YEAR(date) Returns the year number of date


<date>.

YEARS_BETWEEN YEARS_BETWEEN(date1, date2) Computes the number of years be­


tween <date1> and <date2>. Returns
NULL if either of <date1> or <date2> is
NULL.

7.7.2.5 Spatial Functions

Function Syntax Purpose

ST_GeomFromText ST_GeomFromText(Stringwkt,intsrid) Constructs a geometry from a


character string representation.

ST_AsText ST_AsText(ST_Geometry) Returns the text representation of a


ST_Geometry value.

ST_AsGeoJson ST_AsGeoJson(ST_Geometry) Returns a string representing a


geometry in JSON format.

SAP HANA Modeling Guide


214 PUBLIC Additional Functionality for Calculation Views
Function Syntax Purpose

ST_Transform ST_Transform(ST_Geometry , intsrid) Creates a copy of the geometry value


transformed into the specified spatial
reference system.

ST_GeometryType ST_GeometryType(ST_Geometry) Returns the name of the type of the


ST_Geometry value.

ST_SRID ST_SRID(ST_Geometry) Retrieves or modifies the spatial


reference system associated with the
geometry value.

ST_IsEmpty ST_IsEmpty(ST_Geometry) Determines whether the geometry


value represents an empty set.

ST_Envelope ST_Envelope(ST_Geometry) Returns the bounding rectangle for the


geometry value.

ST_Area ST_Area(ST_Geometry) Calculates the area of a polygon.

ST_ConvexHull ST_ConvexHull(ST_Geometry) Returns the convex hull of the


geometry value.

ST_Buffer ST_Buffer(ST_Geometry, Returns the ST_Geometry value that


Doublebuffer , Stringuom) represents all points whose distance
from any point of a ST_Geometry value
is less than or equal to a specified
distance in the given units.

ST_Distance ST_Distance(geometry1,geometry2 , Returns the distance between two


Stringuom) geometries in the given unit, ignoring z-
and m-coordinates in the calculations.

ST_Intersection ST_Intersection((geometry1,geometry Returns the geometry value that


2) represents the point set intersection of
two geometries.

ST_Union ST_Union(geometry1,geometry2) Returns the geometry value that


represents the point set union of two
geometries.

ST_Difference ST_Difference( geometry1, geometry2) Returns the geometry value that


represents the point set difference of
two geometries.

ST_SymDifference ST_SymDifference( geometry1, Returns the geometry value that


geometry2) represents the point set symmetric
difference of two geometries.

7.7.2.6 Spatial Predicates

Function Syntax Purpose

ST_Equals ST_Equals( geometry1, geometry2) Tests if a geometry1 value is spatially


equal to another geometry2 value.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 215
Function Syntax Purpose

ST_Disjoint ST_Disjoint( geometry1, geometry2) Test if a geometry value is spatially


disjoint from another value.

ST_Intersect ST_Intersects( geometry1, geometry2) Test if a geometry value spatially


intersects another value.

ST_Touches ST_Touches( geometry1, geometry2) Tests if a geometry value spatially


touches another geometry value.

ST_Crosses ST_Crosses( geometry1, geometry2) Tests if a geometry value crosses


another geometry value.

ST_Within ST_Within( geometry1, geometry2) Tests if a geometry value is spatially


contained within another geometry
value.

ST_Contains ST_Contains( geometry1, geometry2) Tests if a geometry value spatially


contains another geometry value.

ST_Overlaps ST_Overlaps( geometry1, geometry2) Tests if a geometry value overlaps


another geometry value.

ST_Covers ST_Covers( geometry1, geometry2) Tests if a geometry value spatially


covers another geometry value.

ST_CoveredBy ST_CoveredBy( geometry1, Tests if a geometry value is spatially


geometry2) covered by another geometry value.

ST_WithinDistance ST_WithinDistance( geometry1, Test if two geometries are within a


distance, unit_name) specified distance of each other.

7.7.2.7 Miscellaneous Functions

Calculation view editor supports many SQL functions that return system values and perform various
operations on values, expressions, and return values of other functions.

Function Syntax Purpose

CASE CASE <expression> WHEN <expression> THEN If the expression following the CASE
<expression> [{ WHEN <expression> THEN <expression>}
statement is equal to the expression
…] [ ELSE <expression>] END
following the WHEN statement, then
the expression following the THEN
statement is returned. Otherwise, the
expression following the ELSE
statement is returned if it exists.

COALESCE COALESCE(expression_list) Returns the first non-NULL expression


from a list. At least two expressions
must be contained in
<expression_list>, and all expressions
must be comparable. The result is
NULL if all the expressions are NULL.

SAP HANA Modeling Guide


216 PUBLIC Additional Functionality for Calculation Views
Function Syntax Purpose

GREATEST GREATEST(expression_list) Returns the greatest value among the


specified arguments.

HASH_MD5 HASH_MD5(argument) Returns a 32 byte VARBINARY hash


value of the concatenated arguments.
The hash is calculated using a MD5
algorithm.To ensure unique results
from concatenated arguments, delimit
the arguments with another string

HASH_SHA2 HASH_SHA256(argument) Returns a 32 byte VARBINARY hash


56 value of the concatenated arguments.
The hash is calculated using a
SHA256 algorithm.To ensure unique
results from concatenated arguments,
delimit the arguments with another
string

IFNULL IFNULL(expression1, expression2) IFNULL returns the first non-NULL


input expression. If the data types of
<expression1> and <expression2> are
different, then SAP HANA chooses the
data type with the higher
precedence.For example, between
TIMESTAMP and STRING,
TIMESTAMP has the higher
precedence.

LEAST LEAST(expression_list) Returns the least value among the


specified arguments.

NULLIF NULLIF(expression1, expression2) NULLIF compares the values of two


expressions and returns NULL if
<expression1> equals
<expression2>.If <expression1> does
not equal <expression2>, then NULLIF
returns <expression1>. If
<expression2> is NULL, then NULLIF
returns <expression1>. NULLIF
returns the same data type as
<expression1>. However, if
<expression1> is either TINYINT or
SMALLINT, then NULLIF returns an
INTEGER.

SYSUUID SYSUUID Each time you call the SYSUUID


function, it returns a new UUID value.
SYSUUID calls from multiple
connections are internally serialized to
guarantee unique value generation.

NOT NOT(expression) The NOT operator is placed before a


condition to negate the condition. The
NOT condition is TRUE if condition is
FALSE, FALSE if condition is TRUE,
and UNKNOWN if condition is
UNKNOWN.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 217
Function Syntax Purpose

in in(value1, value2) Returns values that matches values in


a list or subquery.

7.8 Manage Calculation Views with Missing Objects

If objects within a calculation view are missing, for example, if the objects or its references are deleted, then
such calculation views are referred to as broken models. The modeling tool in SAP Web IDE uses proxies to help
you work with broken models and fix inconsistencies.

When you open broken models, the tool displays red decorators for all missing objects that are essential to
successfully activate the calculation view.

Example:

If you have defined a calculation view CV1 on table T1 (C1, C2, C3) such that Attributes A1, A2, A3 is defined on
columns C1, C2, C3 respectively. Now, if you remove column C3 from the table T1, then the attribute A3
becomes inconsistent. In such cases, the tool injects proxies for C3, and when you open the calculation view

CV1 in the editor, tool displays a red decorator for C3 and an error marker for A3 to indicate that it is
inconsistent.

You can resolve inconsistencies in calculation views by performing any of the following:

● Adjusting mappings of inconsistent objects.


● Deleting inconsistent objects.

7.9 Rename and Refactor Calculation Views

Rename a calculation view, its output columns, or input parameters and the tool will automatically adjust the
references of the impacted objects.

Context

Refactoring views or its objects (output columns and input parameters) help automatically adjust the
references of the view in impacted objects. The impacted objects are those objects that have dependencies
with the target calculation view. Thus, refactoring helps retain the behavior of the impacted objects.

For example, if you have created a calculation view using other calculation views as data sources, then
renaming the data source impacts the calculation view that consumes the data source.

SAP HANA Modeling Guide


218 PUBLIC Additional Functionality for Calculation Views
 Note

You cannot refactor objects that may have dependencies with other objects in different SAP HANA
Database Modules. The tool can automatically adjust references only for impacted objects within the same
SAP HANA Database Module.

Procedure

1. Start SAP Web IDE in a Web browser.


2. Rename and refactor calculation views.
a. In the Workspace view, right-click the calculation view that you want to rename and choose Rename.
b. Provide a new name for the calculation view.
c. Choose Rename.
d. If you want to rename the calculation view and also automatically adjust the references in the impacted
objects, in the confirmation dialog box, choose YES.
If you select NO, the tool only renames the calculation view file name.
e. Refactoring calculation views.
In the Refactor Views dialog box, the tool displays the list of calculation views that will be impacted
because of the rename operation. This dialog box also provides information on the refactor support for
each impacted view.

 Note

Manually adjust references in impacted views that do not have the refactor support. For example,
the tool does not support refactoring CDS views. In such cases, manually adjust the references in
CDS views.

f. Choose Refactor to proceed with the refactoring of impacted views.


The tool performs the rename operation and refactors all impacted views. After the rename and refactor
operation is complete, it displays the refactoring status for each impacted view.
a. (Optional) If you want to download the refactor status as .html file to your local system, select the
Download Refactor Details checkbox.
b. (Optional) Select the Build Impacted Views checkbox to build the impacted views.
The build process uses the design-time database artifacts to generate the corresponding actual
objects in the database catalog.
c. Choose Finish.
3. Rename and refactor output columns or input parameters.
a. Open the required calculation view in the view editor.
b. Select the semantics node.

c. In the editor toolbar, choose (Expand Details Panel).

d. In the Columns tab, choose to rename and refactor output columns of the target calculation view.

If you want to rename and refactor input parameters, in the Parameters tab, choose .

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 219
e. For each output column, in the New Name text field, you can enter a different column name.
f. If you want to convert all lower case letters in column names to upper case letters, select the requrired

columns and choose .


g. Choose Check Impact to identify all views that will be impacted because of the rename operation.
The tool displays the list of impacted views. This dialog box also provides information on the refactor
support for each impacted view.
h. If you want to automatically adjust the references in the impacted views, choose Adjust reference.
i. (Optional) If you want to download the refactor status as .html file to your local system, select the
Download Refactor Details checkbox.
j. (Optional) Select the Build Impacted Views checkbox to build the impacted views.
The build process uses the design-time database artifacts to generate the corresponding actual
objects in the database catalog.
k. Choose .

7.9.1 Rename and Refactor Output Columns and Input


Parameters

You can rename output columns and input parameters in a calculation view and the tool will automatically
adjust all references to the output columns.

Context

You can rename multiple objects at a time. The tool will automatically refactor them to adjust the references in
the impacted objects. When renaming, you can also search output columns (or input parameters) for a text or
phrase and replace it with the new text or phrase. For example, you can search for output columns in the
calculation view having the text "customers" and replace it with "CUSTOMERS."

Procedure

1. Open the required calculation view.


2. Click the Semantics view node.

3. In the editor toolbar, choose .


4. Rename and refactor output columns.

a. In the Columns tab, choose to rename and refactor output columns of the target calculation view.

The tool opens the Rename and Adjust References dialog box, which displays all output columns
defined for the calculation view. To rename a column,
b. Select the required column.

SAP HANA Modeling Guide


220 PUBLIC Additional Functionality for Calculation Views
 Note

You can rename and refactor multiple columns at a time.

c. In the New Name textbox, provide the required name.


d. If you want to convert all lower case letters in output column names to upper case letters, select the

required columns and choose .


5. (Optional) Search and replace.
You can also use the search and replace capability for renaming output columns. This means that you can
search output columns based on a text or phrase and replace it with the required text or phrase. The tool
also allows you to use a regular expression to search and replace.

a. In the Rename and Adjust References dialog box, choose .


b. Select the required option.

Option Description

Contains Search all output columns that contain the entered search text.

Equals Search all output columns that match the entered search text.

Regex Search all output columns based on the entered regular expression.

6. In the Search text field, provide the required text, phrase, or regular expression.
7. In the Replace text field, enter the new text, phrase, or regular expression.
8. Check impact and adjust references.
Before you rename an output column, the tool helps you identify those calculation views that will be
impacted due to the rename operation. You can then decide whether you want to automatically adjust the
references in the impacted objects.
a. In the Rename and Adjust References, choose Check Impact.
The tool displays the list of impacted views. This dialog box also provides information on the refactor
support for each impacted view.
a. If you want to automatically adjust the references in the impacted views, choose Adjust reference.
b. (Optional) If you want to download the refactor status as .html file to your local system, select the
Download Refactor Details checkbox.
c. (Optional) Select the Build Impacted Views checkbox to build the impacted views.
The build process uses the design-time database artifacts to generate the corresponding actual
objects in the database catalog.
9. Choose Finish.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 221
7.10 Generate Properties File for Calculation Views

For a calculation view, you can generate a properties file that contains the key-value pairs, such as, name and
description values of calculation views objects.

Context

The tool generates the properties file in the same SAP HANA Database Module that contains the calculation
view with the extension .properties.

For calculation view objects, such as columns, input parameters, variables, and more, you define name and
description values. After generating the properties file for the calculation view, activate the SAP HANA
Database Module that contains this generated file to store the name and description values in the
BIMC_DESCRIPTION table.

You can also translate the name and description values to multiple languages and update the BIMC
_DESRIPTION table. Client tools can read the BIMC_DESCRIPTION table and displays values in the reporting
tools respectively.

Procedure

1. Start SAP Web IDE in a Web browser.


2. In the Workspace view, select the required calculation views.

3. In the context menu, choose Modeling Actions Generate Properties File .

7.11 Generate Calculation View Documentation

Generate a single document that captures all details of a selected calculation view.

Context

Some business scenarios require modeling complex calculation views that includes layers of calculation logic.
In such cases, generating a calculation view documentation helps obtain a snapshot of all key details in a single
document. The tool generates the calculation view documentation in .html format.

For example, the document provides information on columns in the view, the input parameters, variables,
hierarchies, calculated column expressions, notes maintained for calculation views, filter expressions, and
more.

SAP HANA Modeling Guide


222 PUBLIC Additional Functionality for Calculation Views
Procedure

1. Start SAP Web IDE in a Web browser.


2. In the Workspace view, right-click the calculation view for which you want to generate the documentation,
and choose Modeling Actions Generate Document
In a new browser tab, the tool generates the calculation view documentation. The documentation includes
information on all columns, variables, hierarchies, parameters, impact analysis, lineage, and other general
calculation view details.
3. (Optional) Generate documentation for multiple calculation views
You can generate documentation for multiple calculation views in an SAP HANA Database Module at a
time.
a. In the workspace view, select the required SAP HANA Database Module.
4. Browse to the src folder, right-click it and choose Generate Document.
The tool downloads an archive file to your local system. This file contains the individual documentation for
all calculation views in the selected SAP HANA Database Module.

SAP HANA Modeling Guide


Additional Functionality for Calculation Views PUBLIC 223
8 Important Disclaimer for Features in SAP
HANA

For information about the capabilities available for your license and installation scenario, refer to the Feature
Scope Description for SAP HANA.

SAP HANA Modeling Guide


224 PUBLIC Important Disclaimer for Features in SAP HANA
Important Disclaimers and Legal Information

Hyperlinks
Some links are classified by an icon and/or a mouseover text. These links provide additional information.
About the icons:

● Links with the icon : You are entering a Web site that is not hosted by SAP. By using such links, you agree (unless expressly stated otherwise in your
agreements with SAP) to this:

● The content of the linked-to site is not SAP documentation. You may not infer any product claims against SAP based on this information.
● SAP does not agree or disagree with the content on the linked-to site, nor does SAP warrant the availability and correctness. SAP shall not be liable for any
damages caused by the use of such content unless damages have been caused by SAP's gross negligence or willful misconduct.

● Links with the icon : You are leaving the documentation for that particular SAP product or service and are entering a SAP-hosted Web site. By using such
links, you agree that (unless expressly stated otherwise in your agreements with SAP) you may not infer any product claims against SAP based on this
information.

Beta and Other Experimental Features


Experimental features are not part of the officially delivered scope that SAP guarantees for future releases. This means that experimental features may be changed by
SAP at any time for any reason without notice. Experimental features are not for productive use. You may not demonstrate, test, examine, evaluate or otherwise use
the experimental features in a live operating environment or with data that has not been sufficiently backed up.
The purpose of experimental features is to get feedback early on, allowing customers and partners to influence the future product accordingly. By providing your
feedback (e.g. in the SAP Community), you accept that intellectual property rights of the contributions or derivative works shall remain the exclusive property of SAP.

Example Code
Any software coding and/or code snippets are examples. They are not for productive use. The example code is only intended to better explain and visualize the syntax
and phrasing rules. SAP does not warrant the correctness and completeness of the example code. SAP shall not be liable for errors or damages caused by the use of
example code unless damages have been caused by SAP's gross negligence or willful misconduct.

Gender-Related Language
We try not to use gender-specific word forms and formulations. As appropriate for context and readability, SAP may use masculine word forms to refer to all genders.

SAP HANA Modeling Guide


Important Disclaimers and Legal Information PUBLIC 225
www.sap.com/contactsap

© 2019 SAP SE 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 SE or an SAP
affiliate company. The information contained herein may be changed
without prior notice.

Some software products marketed by SAP SE and its distributors


contain proprietary software components of other software vendors.
National product specifications may vary.

These materials are provided by SAP SE or an SAP affiliate company for


informational purposes only, without representation or warranty of any
kind, and SAP or its affiliated companies shall not be liable for errors or
omissions with respect to the materials. The only warranties for SAP or
SAP affiliate company 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
SE (or an SAP affiliate company) in Germany and other countries. All
other product and service names mentioned are the trademarks of their
respective companies.

Please see https://www.sap.com/about/legal/trademark.html for


additional trademark information and notices.

THE BEST RUN

You might also like