0% found this document useful (0 votes)
38 views

SAP HANA Studio, Build A Calculation View and View The Data in MS Excel

hana studio _calculation_view

Uploaded by

surya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

SAP HANA Studio, Build A Calculation View and View The Data in MS Excel

hana studio _calculation_view

Uploaded by

surya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

Products
Products Industries
Industries Support
Support Training
Training Community
Community Developer
Developer Partner
Partner  
Tutorial Navigator /
About
About
Tutorial

SAP HANA Studio, Build a Calculation View and View the Data in MS
Excel
0%
1 2 3 4 5 6

Details

// Explore More Tutorials

SAP HANA Studio, Build


a Calculation View and
View the Data in MS Excel
Lsubatin 01/12/2018

Beginner  25  SAP HANA, Tutorial, Beginner,


min. SAP HANA studio, Big Data

In this tutorial, you will go through all the steps to import data
from a MS Excel Spreadsheet, model a simple Calculation
view and viewing the results in a pivot table using the HANA
MDX connector.

You will learn

In this tutorial, you will go through all the steps to import data
from a MS Excel Spreadsheet, model a simple Calculation
view and view the results in a pivot table using the HANA MDX
connector from MS Excel. You will rst create the basic setup
within an XS Project.

1
Step 1: Download and
Install SAP HANA
Client
First, you will need to download and install the SAP HANA
Client to enable the MDX Connector. You can nd it in the
Marketplace, in the SAP Software Download Center:

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 1/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

Follow the instructions from the installer to complete the


installation.

2
Step 2: Create the XS
Project and Core Data
Services artifacts
In SAP HANA Studio, from the SAP HANA Development
perspective, create an XS Project by selecting File->New-
>XS Project. If you do not see the XS Project option, go into
Other and look for it under the Application Development
menu inside SAP HANA.

Click on Next, choose a repository, add a name for a package


and untick the Add project Folder as Subpackage.

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 2/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

Click Next, add a name for a schema and for the Data
De nition (.hdbdd) le

You can now declare a context in a Core Data Services (CDS)


artifact. This context will serve as a group for the two design-
time entities (tables) that will hold the data you will import
and the data types you will create.

Enter the following code into the .hdbdd le:

Copy

1 namespace mdx_parks;
2
3 @Schema : 'PARK'
4 context parks {
5
6 /**`Type` is to declare reusable field or structur
7
8 Type tyObjectID : String(8);

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 3/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel
9 Type tyParkID : String(7);
10 Type LString : String(200);
11 Type MString : String(80);
12 Type SString : String(20);
13 Type TString : String(2);
14
15
16 /** An entity becomes a table **/
17
18 entity Park {
19
20 key OBJECTID : tyObjectID;
21 key ParkID : tyParkID;
22 ParkName : MString;
23 ParkType : SString;
24 ParkStatus : SString;
25 DevelopmentStatus: SString;
26 ParkPlanningArea : SString;
27 MgtPriorty : SString;
28 MgtAgencyName : MString;
29 MgtAgencyType : SString;
30 Landowner : MString;
31 OwnerType : SString;
32 Acreage : Decimal(10,2);
33 AcreSource : SString;
34 Address : MString;
35 CityMuni : SString;
36 County : SString;
37 State : TString;
38 StreetNum : String(6);
39 StreetDirection : TString;
40 StreetName : MString;
41 StreetType : String(4);
42 Zip : String(5);
43
44 };
45
46 /** The following fields in the file have been lef
47 StatusCmnt, Comments, Classic**/
48
49 entity Amenities {
50 key ID : String(32);
51 key ParkID : tyParkID;
52 park: Association[1] to Park on park.ParkID =
53 AmenityType : MString;
54 CourtCount : Integer;
55 DescriptionText : LargeString;
56 HasSwingset : String(5);
57
58 };
59
60
61 /**Fields Park Name, FieldCount,FieldSurface, AgeG
62 not included **/
63
64
65 };
66

The structures de ned for these three entities match those of


the les we will use later, except for some elds that have

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 4/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

been intentionally left out.

Right-click on the project, go down to Team and click on the


Activate All button.

3
Step 3: Grant
permissions to the
newly created schema
From the Systems tab, open the Security folder and look for
your user ID. Double-click on it to open your User
Administration page.

Click on the Object Privileges tab and the on the + sign to


add the schema you need access to:

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 5/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

Select the schema you have just created:

Note: You may need this done by a user with


administration permissions.

Flag permissions to Delete, execute, insert, select and Update


your new schema.Once nished, press F8 or click on the
green arrow on the top right corner to deploy the changes.

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 6/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

You can now go into the Systems tab and look for the Schema
and tables:

4
Step 4: Import data
into your tables
This example uses data from the Open Data City of Boise site.
If you choose another dataset, you need to adapt the entities
and types created in the previous step to match the structure
of that dataset.

The datasets in this example are the Boise Parks Facilities


Open Data and the Boise Parks and Reserves Open Data CSV
les.

Go into File and then Import.

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 7/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

In the SAP HANA Content folder, choose Data from Local


File and then click on Next.

Choose your target system (where your schema and tables


are):

Click on Browse to select one of the two les you will import.
This example starts with
Boise_Parks_and_Reserves_Open_Data.csv, which
contains the date for the table Park. You could also start with
Boise_Parks_Amenities_Open_Data.csv, which contains
the data for the table Amenities. once you select the le,
click on Open.

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 8/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

Note: You could also use .xlsx or .xls le formats.

Click on the Header Row Exists to indicate that the rst row
contains the names of the columns. Click on Select Table to
search for the table to which you will import the le. This
example uses the table Park.

Click on Next. If you are importing a le with a Header Row


and the names of the rows match the names in the table, you
can choose the Map By Name, like in this example. If you do
not have a header row or the names do not match, you can
choose to perform the mapping manually by dragging the
elds from the source le on the left to the target table on the
right.

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 9/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

Perform the same import procedure with the Amenities table


using the Boise_Parks_Amenities_Open_Data.csv le.

Right-click on the tables to Open Data Preview and see the


les loaded. You can quickly explore the data in the Distinct
Values and Analysis tabs:

Hint: If you click on the Show Log button on the top


right corner of the data preview in SAP HANA Studio,
you can see the SQL Query and the server processing
time.

5
Step 5: Create a
Calculation View
You will now create a Calculation View. A calculation view can
perform complex calculations joining di erent tables,
standard views and even other calculation views as sources.

From the Project Explorer tab in SAP HANA Studio, right


click on the project, then on New and then look for the
Calcuation View under SAP HANA / Database
Development

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 10/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

Enter the name for your calculation view and click on Finish.

Add two projection nodes by dragging and dropping


Projection nodes from the Nodes lateral bar. These nodes
will be used to join the parks to their Amenities and add a
lter later.

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 11/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

Hover on the nodes and a + sign will appear on the right.

Click on it to select the one of tables (either Park or


Amenities) to be projected. Repeat the same for the other
table so you can select all of the elds for output. You can
either click on the circle on the left of each individual eld or
right click on the top of the table node and select Add all to
Output.

For the Amenities, leave out the DescriptionText eld from


the output as it is not supported by this type of view.

Drag and drop a Join node from the Nodes bar on the left. To
connect the tables, drag and drop the circles on the top of
each Projection node into the Join node.

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 12/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

Click on the Join Node to connect the key elds by dragging


the ParkID from the left into the ParkID eld from the right:

Add all the elds to output (except for the ParkID eld from
amenities, to prevent it from being duplicate) and set the
Join Type to Left Outer so that Parks that do not have any
amenities are also included in the results.

Finally, drag and drop the circle on the Join node into the
Aggregation node. Add all the elds in the Aggregation to
Output and click on the Semantics node.Use the Auto Assign
button to automatically set the type (measure or attribute)
for each eld.

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 13/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

The Auto Layout button at the bottom of the graphic


model makes the diagram prettier.

Activate your view using the green arrow on the top:

And click on Raw Data to see your results:

6
Step 6: Connect to
your instance using

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 14/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

the MDX connector


Open a new spreadsheet in MS Excel. In the Data ribbon,
choose From Data Connection Wizard in the Other
Sources menu.

Choose Other/Advanced and click Next.

If you completed Step 1 successfully, you will see HANA MDX


Provider at the bottom. Select it and click on Next.

Enter the connection details to your SAP HANA database and


test the connection before clicking on OK.

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 15/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

Hint: You can right-click on the system, and open


Properties to see your IP or host name followed by
port 3xx15, where xx is your instance number.

After the connection is established, choose the package


(database to MS Excel) and the calculation view (also known
as, Cube) and then click Finish.

Review the Import Data options. Keep the Pivot Table and
click on OK.

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 16/17
9/30/2018 SAP HANA Studio, Build a Calculation View and View the Data in MS Excel

You can now use Excel to execute OLAP queries against SAP
HANA and create Pivot Tables and Pivot Charts.

Next Steps
Select a tutorial from the Tutorial Navigator or the
Tutorial Catalog

Share & Follow


Privacy Terms of Use Legal Disclosure Copyright Trademark Cookie Preference Sitemap Newsletter Text View

https://developers.sap.com/india/tutorials/studio-view-data-calculation-mdx.html 17/17

You might also like