Reminder: This tutorial is part of a mission, in which you will help Alex, the CEO of Best Run Travel, to answer a concrete business question with SAP HANA Cloud, SAP HANA database.
Alex needs to know the top 5 partners of their agency and wants to find out the days with maximum booking of each partner.
In this tutorial, you will learn how to make the calculation view you created previously available to others in the organization by creating a new role and granting this role access to the view.
Step 1Generate a SELECT statement on the column view
โ
To allow others to see the results of your calculation view, you need to grant them the privilege to run SELECT statements on this calculation view.
To run SELECT statements on calculation views in the new environment, first make sure that the you have the correct schema name. This schema is not the SFLIGHT schema we previously created, but rather the schema automatically created for the calculation view.
To find out the schema name, open the SAP HANA database explorer.
Find your HDI container in the catalog.
Not sure how to find the HDI container of your project in the catalog?
Unless you specified a name for your container manually upon creation of your project, the default name will look something like this:
SharedDevKey@[name of your dev project]-hdidb-[sequence of characters] ([name of your space])
In our example, it is listed as follows:
SharedDevKey@BestRunTravel-hdidb-ws-g6mq2 (dev)
Alternatively, you can go to SAP Business Application Studio and click on the HDI container iconContainer, which will directly open the right container in the catalog.
Click on Column Views.
Right-click on the column view name on the bottom panel and choose to Generate a SELECT Statement.
DBX Catalog
This will open the SQL Console on the main area of the screen with the SELECT statement. On line 7 you can see a FROM clause with two arguments separated by a .. The first part is the schema name, the second part is the calculation view name.
Copy the name of the schema and save it for later, for example, using a text editor.
Keep this SQL console open.
Select Statement
Step 2Create a role
+
Great, now that you have the right schema name, next you will have to grant the authorization to SELECT on the Calculation View. This is done by creating an .hdbrole file in your development project that grants the SELECT privilege.
Go to your project in SAP Business Application Studio and start your development space if needed.
You need the command SAP HANA: Create HANA database artifact that you got to know in the previous tutorial. Access it by clicking on View menu and selecting Command Palette or press Ctrl+Shift+P. Unless you see it in your recently used commands, type SAP HANA and select SAP HANA: Create HANA database artifact from the list.
In the wizard, make sure the path to save the role file is in the src folder of your project.
Choose the database version HANA Cloud.
Select the artifact type as Role (hdbrole).
Name your role PublicAccessSchema.
Finally, click on Create.
BAS Create role
Your role will appear in the file explorer of your project and you can add privileges to it.
Step 3Add privileges to the role
+
In this step, you have two options to add privileges to your role: You can use the Role Editor wizard or the Text Editor. Click on the option you prefer under the title of this step.
The goal in this step is to add the schema privileges SELECT and EXECUTE to the role PublicAccessSchema
Click on the .hdbrole file. This will open the role editor.
Click on Schema Privileges and check the boxes in the column Privileges for SELECT and EXECUTE.
No other options need to be checked, so you can close the role editor.
BAS Role editor
Right-click on the .hdbrole file, select Open with, then choose Text Editor when prompted at the top of the screen.
BAS Code editor
Paste the following statements there. Alternatively, you can download this code from our public GitHub repository.
Note that, if you have added a namespace to your db folder, you will have to edit the syntax to include that. Before PublicAccessSchema, add your namespace and ::.
Deploy the .hdbrole file by clicking on the deploy icon (Deploy) next to it on the SAP HANA Projects panel or on the top right corner of the main panel.
After you are done, deploy the whole project again. When that is completed successfully, you may continue.
Step 4Create a new database user in SAP HANA Cloud Central
+
Now that you have the role created and granted privileges to this role, it’s time to grant this role to a user. We will create the public user report that shall have read-only access to the calculation view.
Open the SQL Console in SAP HANA Cloud Central. Make sure that the connection is opened for an user that has system privileges ROLE ADMIN and USER ADMIN, e.g., database user DBADMIN.
Paste the following statement in the SQL Console. Change the password in the statement and then run.
Using the clause NO FORCE_FIRST_PASSWORD_CHANGE is not considered a security best practice! We will only use this option for the purpose of this tutorial, in our example to make a user available to multiple individuals. If you create users in your productive environment, please consider forcing a password change for the first log in and giving individuals different users.
create user report
Now that our new user report is created, we need to grant the user access to the role PublicAccessSchema.
Use the following statement.
SQL
GRANTHDI_TUTORIAL."PublicAccessSchema"toreport;
Notice that the schema name is the value you copied in the beginning of this tutorial.
Custom vs. default roles
You can also use the default role that has the container name.default access. As soon as an HDI container is created, the default access role is created. You can find the name of the role by using the statement SELECT * FROM ROLES
The role you are looking for should consist of the schema name and the role name access_role.
default role resized
If you don’t need a customized role, you can use this one. In a productive system, we recommend creating your own roles with just the privileges needed.
Step 5Connect as the new user
+
You have successfully created the new user report and assigned it a role to access your calculation view. With the new user credentials, anyone who has the credentials for this user can run SELECT statements on your calculation view.
To test this, first log in with your new user by typing the following statement:
SQL
CONNECTreportPASSWORDPassword1;
You should now see at the top of the screen, over the SQL console the user you connected with.
Since you granted this user SELECT privileges, you should be able to now run the statement below with the user report.
And with that last step, you have completed the last tutorial of this mission! You learned how to create a new user role and how to grant access to your calculation view using SAP Business Application Studio and SAP HANA Database Explorer.
Congratulations! You successfully completed this mission!
You achieved your goal of helping Alex find the business insights they were looking for and share these insights with others!
Alex Banner final
Throughout the tutorials of this mission, you have learned how to provision your first SAP HANA Cloud, SAP HANA database instance, how to use the different SAP HANA Cloud tools, how to import and query data, how set up a development project, create and calculation view and how to make it available to others within your organization.
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 6
1. Generate a SELECT statement on the column view2. Create a role3. Add privileges to the role4. Create a new database user in SAP HANA Cloud Central5. Connect as the new user6. Knowledge Check
Joule
AI Notice
Joule is an AI assistant. Generative AI may produce inaccurate, incomplete, or biased information. Always verify important details before acting on them.
Conversations are sent to SAP-hosted large language models for processing. Do not include personal data, credentials, or confidential information in your messages.
Joule's responses are based on the SAP tutorial catalog and may not reflect the latest product changes. For authoritative guidance, consult the linked tutorials and official SAP documentation.