You are on page 1of 15

| HOW-TO PAPER

[ SAP HANA Tutorial ] mayato How-To Papers in the Area of Business Intelligence
Title: Author(s): Topic Published: Create some analytic privileges on a table Thorsten Füg SAP HANA December 2012

Overview
This tutorial describes how to create some simple analytic privileges on a table in SAP HANA. You limit the access to a table (which is in default client independent) for a user with the help of analytic privileges. Prerequisites o You have access to an SAP HANA system. o You have SAP HANA Studio installed on your machine. o You have SAP HANA Clients installed on your machine. Topics In this tutorial you will learn how to: 1. Create a table and insert some data 2. Create a user and assign a role and SQL privilege 3. Create an analytic privilege 4. Assign the analytic privilege to the user you created in the previous step 5. Delete a user The estimated completion time for this tutorial is 40 minutes. Using a simple data model, you will learn the basic steps about how to model data in the SAP in-memory computing studio.

In SAP HANA Studio go to your schema. the name is FINANCIALS) and create the following fields: Fieldname ID MANDANT COUNTRY DATE REVENUE COTS ERNINGS CURRENCY Settings mark the field as key Dim 3 Dim 20 Dim 6. There you will find a folder named tables.Create a new tables in SAP HANA 1. In the screen below the schema TUTORIALS is selected. not Null Dim 6. 2. Here you can add a new table using a right click. Not Null Dim 3 Data type INT CHAR VARCHAR DATE DECIMAL DECIMAL DECIMAL CHAR 2 . not Null Dim 6. Choose a name for the table (in this exercise.

3 .

SQL code: Table FINANCIALS create column table "<YOUR SCHEMA>". "REVENUE" DECIMAL (8. "COSTS" DECIMAL (8. "COUNTRY" VARCHAR (20) null default ''. As final step in this section deploy the table Fill the new table with data In the first step right-click on the new table and choose “Generate” -> “Insert Statements” from the context menu.2) not null."FINANCIALS"( "ID" INTEGER not null. "CURRENCY" CHAR (3) null default ''. "DATE" DATE null.2) not null. "EARNINGS" DECIMAL (8. primary key ("ID")). 4 . 3. "MANDANT" CHAR (3) null default ''.2) not null.

'CNY').00.2012'.20000.'01.'400'.2012'.'USD').00. insert into "<YOUR SCHEMA>".07.'Germany'.44.'EUR').4000."FINANCIALS" values(8.14000.10000.'100'.00.'EUR').82.29000."FINANCIALS" values(7.00.'100'.20000. insert into "<YOUR SCHEMA>".1000."FINANCIALS" values(5. insert into "<YOUR SCHEMA>".00. After that. SQL code insert statment insert into "<YOUR SCHEMA>".'England'.'GBP').'EUR').2012'.07.00.'100'.00.13999.'02.15000."FINANCIALS" values(2."FINANCIALS" values(6.'02.'03.'01.99000.00.50000.70000.99.2012'.444.'02.'200'.00.'200'.'Germany'.5000.'300'.2012'. the SQL editor will appear.00.'Germany'.'China'.07.18.07.'300'.'EUR').'USA'. insert into "<YOUR SCHEMA>".'Germany'.1111.15000.2012'.00.07. 5 . insert into "<YOUR SCHEMA>".'CNY').99."FINANCIALS" values(3.'USA'. Enter the following SQL statements to fill the table with data.'01.00.00.'Germany'.800.500.00.'CNY').00.'100'.07.21000. open the data preview with right click."FINANCIALS" values(1.19000.'01.20000."FINANCIALS" values(10.1999.00.07.07.07.5000.'01.00.50.00.After that.07.'300'.'EUR').200.17000.07. insert into "<YOUR SCHEMA>".25000. insert into "<YOUR SCHEMA>".5000.07.00.4000."FINANCIALS" values(9.00.55.10. insert into "<YOUR SCHEMA>".67.00.'100'.20000.5000.5000.'China'.2012'. insert into "<YOUR SCHEMA>"."FINANCIALS" values(12.500.'200'.2012'.'03.00.'USD').11.2012'.00.'04.00.50.45.18000.55000.2012'.2012'."FINANCIALS" values(11.'USA'. insert into "<YOUR SCHEMA>"."FINANCIALS" values(4.'USD').'China'.666.2012'.'03. insert into "<YOUR SCHEMA>".1000.

Click “Next” after naming.Finally. and also a description. right-click on your package and choose “New”. Ensure that you adhere to the SAP naming convention (ATR_) 6 . your filled table will look like the screen shown below: Create a new attribute view To create a new attribute view. Choose a name for the new attribute view.

Next. After that. choose the schema and table you created at begin of this tutorial. 7 . add ID as the key attribute and all other fields as attributes. click “Finish”.On the next screen.

Finally. 8 . save and activate the attribute view… … and take a look at the to check that everything went fine.

On the next screen enter a name and click “NextEnsure that you adhere to the SAP naming convention (AP_). you can create a new analytic privilege by right-clicking on the package. You only have to enter a name. 9 . After that. If you don’t see the folder.Create a new analytic privilege In the first step. With a right-click on this folder you can create a new package. switch to the modeler perspective (right corner at the top of SAP HANA Studio). go to the folder “Contents” on your SAP HANA Workspace.

you select the field “MANDANT” (client). Then leave the screen by selecting “Finish”. At this point. In the next step. define a new associated attribute restriction. a new window appears. In our case. 10 .After that choose your package and add the attribute view you created before.

Then a new entry named equal appears in the red marked area in screenshot. Here you can search for client (mandant) “100” like on the screenshot below. Near to the operator you will find a browse button for selecting a value. Here. select “Add” as shown in screenshot. To do this. If you click this button. too. 11 . you will see a new popup. Now you must assign a restriction for that field. but in our case it should be equal. Finally you can save and deploy the analytic privilege using this button: In the job log you can take a look at the corresponding success message. you can see the new entry in the area outline in red in the screenshot at the top this page. you can also choose another operator.After that.

. performe do a data preview on the actual attribute view. At this moment.Performe a data preview Before we assign the new privilege to our user. To do this. you will see other entries apart from the entries of MANDANT 100. right-click on your attribute view in the content folder and choose “Data Preview”. 12 .

add your attribute view and choose “SELECT” privilege. In this tutorial. After that. This role includes all thenecessary basic rights for analysts.Assign the new analytic privilege To apply the new analytic privilege to the table FINANCIALS. enter a user name and password and add the role ANALYZER. In the next window. After that. switch to the tab named “SQL Privileges”. Next. add your new analytic privilege: 13 . you assign the analytic privilege a new SAP HANA user. right-click on “Users” and choose “New User”. you switch to the folder “Catalog” -> “Authorization” -> “Users” in the navigator pane. To do this. you must assign the privilege to users.

For analyses. For this test scenario. right-click on your current connection and choose the menu entry “Add Additional User…” On the screen that appears. To do this. As an analyst you do not have any rights to see tables saved in schemas.Finally. enter username and password of the new user with role “ANALYZER”. In the content folder. go to the new connection and choose the content folder. the modeler creates attribute and analytic views. you created an attribute view in the previous steps. Test the new analytic privilege Now you can add a new connection for this user to SAP HANA studio. After these initial steps. Browse to the FINANCIAL attribute view and open the data preview with a right click. click on the deploy button . the tutorial package should be available. 14 .

too. Choose “Delete” and select the option “Restrict”! Delete the new connection for M_ANALYST using the right mouse-button. References Part of this tutorial is inspired by SAP training material 15 . delete the new user M_ANALYST. before assigning the privilege. which is in the area “Users”. To do this. you could see the whole content. Clean up the system after ending this tutorial. First.Here you can see the data restricted by the analytic view to client (mandant) 100. go into your own connection to the authorization folder and right-click on M_ANALYST. Previously.