Professional Documents
Culture Documents
INTRODUCTION This document describes how to build a simple report using data stored on SAP HANA. By the end of this tutorial, you will have a pivot table in MS Excel running on SAP HANA. Prerequisites You have access to a SAP HANA system. You have SAP HANA Studio installed on your machine. You have SAP HANA Clients installed on your machine. You have installed SAP HANA Client libraries for connectivity from MS Excel
For more information about SAP HANA and SAP in-memory database landscape, installation and administration, see the resources listed in Appendix A. Topics In this tutorial you will learn how to: 1. 2. 3. 4. Create tables Load data from csv files Prepare and organize your data Consume Analytical View in Excel
Using a simple data model, you will learn the basic steps on how to model data in the SAP in-memory computing studio and then consume the data in MS Excel. In this tutorial, you are going to use the e-fashion data. The main table, SHOP_FACTS, contains all the bills of several fashion shops in the US. The screenshot below shows some content of the table.
3 - DRAFT
In order to do this tutorial, you will be provided a ZIP file, called E2EModelingTutorialData.zip, which contains CSV data that you have to load into the SAP in-memory database. It will also contain SQL commands for you to run to create the tables.
4 - DRAFT
1.1 Install SAP HANA Studio The first thing to do is to install the SAP HANA studio. 1.2 Create the E-Fashion Tables In the SAP In-memory Database Follow the instructions to create the e-fashion tables onto SAP in-memory database: 1. Copy all SQL statements in the file SQLStatements.txt in an SQL view of your In-Memory Computing Studio. 2. Modify the CREATE COLUMN TABLE statements according to your schema name. For example: CREATE COLUMN TABLE <SCHEMA_NAME>.SHOP_FACTS could become CREATE COLUMN TABLE MY_EFASHION.SHOP_FACTS 3. Run the SQL statements.
Once the tables are created, you will see them listed in the navigator pane.
5 - DRAFT
1.3 Load The E-Fashion Data Into The SAP In-memory Database To load the data to your SAP In-memory database, follow the following instructions: 1. Copy the files from the ZIP file to your database server. 2. Copy all SQL statements in the file SQLStatements.txt in the SQL view of your SAP in-memory computing studio. 3. Modify the load statement according to your file location. For example, LOAD FROM '<TO BE CHANGED>\EFASHION_SHOP_FACTS.CTL' could become LOAD FROM '/tmp/EFASHION_SHOP_FACTS.CTL' 4. Run the SQL statements. 5. Verify that all the files *bad.txt are of size 0, which means the import was successful.
6 - DRAFT
Next step is to make sure the data is successfully loaded: 1. Right mouse click on a table name.
2. Click Open Data Preview to see all the records loaded in the table.
7 - DRAFT
1.4 Model A Simple Attribute View Basically, during the modeling at least one analytic view needs to be created. Typically, in case of more complex data schemes, several attribute and analytic views are to be created. The attribute view defines all the attributes typically text based data shown in the exploring UI. The tables used there are linked with the fact tables via keys. For each table, which contains attributes to be shown later on an attribute view needs to be defined. In this example, four attribute views will be defined and used in the analytic view. These tables are also called dimension tables or just dimensions. Prerequisites 1.5 Running installation of SAP in-memory database components and SAP in-memory computing studio Configured Modeler To follow the steps described below, you need to have the e-fashion data in your system.
Define the attribute views As mentioned above you start the modeling with the definition of the attribute views. 1. In the SAP in-memory computing studio, change to the Information Modeler perspective. 2. Create a package where you are going to put the group of views that you will be creating. Right mouse click on Content. Click New -> Package. Give the package a name, efashion, for example. 3. Navigate to the folder Attribute Views in the Navigator pane.
8 - DRAFT
4. 5.
Right mouse click on Attribute Views. Select New -> Attribute View. Choose a name, for example AT_ARTICLE. Choose the table ARTICLE_LOOKUP.
6.
Define the attributes a. ARTICLE_ID as key attribute. b. CATEGORY and FAMILY_NAME as attribute.
9 - DRAFT
7. Define the attribute views for the tables ARTICLE_COLOR_LOOKUP, CALENDAR_YEAR_LOOKUP and OUTLET_LOOKUP and choose the attributes listed below:
Key Attribute
10 - DRAFT
Key Attribute
Key Attribute X
8. Save all views. You will see the views that you just created listed under Attribute Views.
9. Activate all attribute views by right mouse click on each attribute view in the Navigator pane and choosing Activate in the menu. 1.6 Model A Simple Analytic View
After defining the attribute views, the next step is to define the analytic view(s). You can define more than one analytic view depending on your users need for further investigating the data. To keep this example small and simple, you are going to define only one analytic view.
11 - DRAFT
1. Choose the folder Analytic Views in the Navigator pane. Right mouse click on Analytic Views and select New -> Analytic View. Choose a name, for example AN_EFASHION. 2. Select the fact table SHOP_FACTS. Click the Add button and then the Finish button. 3. In the Data Foundation tab of the analytic view (see lower left corner in the content area) select the attributes and the key figures according to the table below:
AN_EFASHION
Column ARTICLE_ID COLOR_CODE WEEK_ID SHOP_ID MARGIN AMOUNT_SOLD QUANTITY_SOLD Note: You could also mark several attributes to select them as for example measures. Use SHIFT or CTRL to select several attributes at a time (like in Windows Explorer). Attribute X X X X X X X Measure
4. Change to the tab Logical View. 5. Insert the previously defined Attribute views AT_ARTICLE, AT_ARTICLE_COLOR, AT_CALENDAR_YEAR and AT_OUTLET. 6. Define the joins between the attribute views and the fact table by selecting the key column in the attribute view, pressing the left mouse button, and while still pressing the left mouse button drawing the join to the target column, the key field in the fact table. In this example, the key fields are named identically in the dimensions and the fact table. Only the attribute view AT_ARTICLE_COLOR needs two joins. Connect the columns ARTICLE_ID and COLOR_CODE to the corresponding columns in the fact table. Moreover, it is necessary to specify the join type as leftOuter join in the Properties tab. The analytic view should now look like the screen shot shown below.
12 - DRAFT
7. Save the view. 8. Activate the analytic view by a right mouse click on the view in the Navigator pane and choosing Activate in the menu. Make sure, that the activation runs without any error.
1.7
There are different ways of exploring the data in the SAP In-memory database. In this tutorial, to make things simple, we are going to consume the data using MS Excel. Beside a running SAP in-memory database installation with the data and configuration described above, you need to have a connection configured between MS Excel and the HANA system in order to consume the column views of your SAP in-memory database system.
13 - DRAFT
1.8
1. Make the connection to your HANA system. In MS Excel, click Data -> Get External Data -> From Other Sources -> From Data Connection Wizard. 2. In the Data Connection Wizard, click Other/Advanced. Click Next. 3. From the list of OLE DB Providers, scroll to the bottom of the list and select SAP HANA MDX Provider. Click Next.
14 - DRAFT
4. In the Data Link Properties window, Connection tab, enter your SAP HANA system information and your log in credentials. Click OK.
5. Select the database that contains the data that you want. Click on the name of the Analytic View or cube. Click Finish.
15 - DRAFT
Now that you have established your connection to the SAP HANA database and specified the data that you want to use, you can start exploring them in MS Excel, using a Pivot Table.
16 - DRAFT
Topic
Guide/Tool
Quick Link
https://service.sap.com/hana SAP HANA 1.0 Master Guide SAP HANA 1.0 Installation Guide
http://help.sap.com/hana SAP HANA 1.0 Technical Operations Manual SAP HANA 1.0 Security Guide
https://service.sap.com/hana
17 - DRAFT
APPENDIX B: GLOSSARY
18 - DRAFT