Professional Documents
Culture Documents
HC Workshop Session-02 Workbook
HC Workshop Session-02 Workbook
GET STARTED
Welcome to the Digital Hands-on Workshop Series on SAP HANA Cloud! We’re excited to offer you a detailed,
hands-on introduction into your SAP HANA Cloud!
WELCOME! 3
CONTENT OVERVIEW 4
1
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
CREATING A FLOWGRAP H 34
saphanajourney.com/hana-cloud
© 2020 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.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop or release any functionality mentioned therein. This document,
or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its
affiliated companies at any time for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are
subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they should not be relied
upon in making purchasing decisions.
service names mentioned are the trademarks of their respective companies. See www.sap.com/copyright for additional trademark information and notices.
2
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
WELCOME!
Learn in this session how to add remote sources and virtualize data from these sources to your SAP HANA Cloud,
HANA database as well as how to use flowgraphs to load data to different tables. You will also learn how to manage
the roles and privileges necessary for these steps. This includes:
Your presenters:
3
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
Content overview
In session 1, you have created a development project with an empty table and three roles. You then deployed this
project on your trial instance of SAP HANA Cloud, HANA database. In session 2, we will bring data into this table
and make use of the roles you have created.
We have prepared an SAP HANA Cloud, HANA database instance T2 that is connected to an SAP HANA Cloud, data
lake. In this session, you will watch us first while we prepare objects in this instance. You will then connect to it with
your own SAP HANA Cloud, HANA database trial instance that we will refer to as 'T1'. In T1, you will set up a remote
source and virtual tables that point to T2 and the SAP HANA Cloud, data lake.
4
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
In the second phase of session 2, we will create a flowgraph to distribute data to the different data sources that will
then be used in a simple calculation view. This calculation view will be created in your development project in SAP
Business Application Studio and deployed on your SAP HANA Cloud, HANA database.
5
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
2. Make sure your SAP HANA Cloud, SAP HANA database is running in your trial account.
3. Make sure your development space is running in SAP Business Application Studio.
4. All code necessary for this session can be found in this workbook. You can also access it via:
5. For this session, you will also need a sample dataset, which you can access via:
If you need help with the preparation, post your questions in the SAP community using the hashtag
#saphanacloud.
Note that during your trial, your instance will be automatically stopped overnight, according to the server
region time zone. That means you need to restart your instance before you start working with your trial
every day.
6
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
ADDITIONAL RESOURCES
· SAP HANA Cloud Product Page
· Data and Analytics Learning Center featuring free in-depth content:
o SAP HANA Cloud Onboarding Guide
o Interactive learning mission on SAP HANA Cloud
· Recommended related Learning Tracks:
o Moving a project with calculation views from XS Advanced to SAP HANA Cloud
o How to create a CAP development project in SAP Business Application Studio and bind it to SAP
HANA Cloud
· Related Technical Documentation:
o SAP HANA Cloud
o SAP HANA Cloud Deployment Infrastructure Reference Guide
o SAP HANA Cloud Modeling Guide for SAP Business Application Studio
· Get a Demo of Implementation Services from SAP
7
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
Click on Actions in the bottom right corner of the tile and you can see the following options:
Monitor landscape will open the SAP HANA Cloud Central. There, you can start and stop your instances and check
on their status.
Administer <instance name> will open the SAP HANA Cockpit in a new tab. There, you can monitor your databases,
create users and assign roles as well as set up replication services.
8
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
Execute SQL and explore objects will open the SAP HANA Database Explorer. There, you can access your data and
interact with your databases.
To access SAP Business Application Studio, you can click on Trial Home at the top bar in SAP BTP cockpit. Then,
under Quick Tool Access, you will find SAP Business Application Studio. Alternatively, you can find it in the Service
Marketplace on your Subaccount level.
9
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
At the bottom you find the SAP HANA PROJECTS panel where you can deploy your project and for example open
the HDI container in the SAP HANA Database Explorer. Whenever you add a new database object that can be
deployed to your HDI container, it will appear in this panel and you can deploy it. In this area you can also check the
database connections of your project.
Moving your cursor to the name of an object, folder, or connection in this panel, you will see different icons:
· This icon will open the HDI container in SAP HANA Database Explorer
· This icon will deploy an object, folder, or the whole project to the HDI container.
· This icon (only on the Database Connections level) allows you to create or add a database service.
· This icon / allows you to bind (green colour) or unbind (grey colour) a service connection .
10
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
You do not have to follow the steps in this section; they are only for your reference to understand the
preparations we have made in the instance T2, you will connect to later on.
In this section, we will show you what preparations we have made beforehand so you can connect to our instance
T2. The steps illustrate how you can prepare an instance that you want others to connect to.
1. In the SAP HANA Database Explorer, we used the database connection of our database user DBADMIN.
2. First, we created a user T2 that you can later use to connect to this instance.
When you connect to this database later, you will need the credentials of this user for connecting to this
instance.
Username: T2
Password: DnATBG!1
3. We then granted this user permissions to create tables in SAP HANA CLOUD, data lake, to create schemas,
11
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
4. Next, we added a database connection using this new user. To do that, we clicked on the DBADMIN
database connection in the catalog and selected Add Database with Different User and put in the
5. With this new database connection as the user T2, we opened a new SQL Console and created a table
TLOG_F_O in the schema T2. We used the same table definitions as you did in session 1 for creating the
table TLOG_F_C.
12
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
6. To create a table in the SAP HANA Cloud, data lake, we used a procedure that allows creating the table
7. For you to be able to connect to this table in our SAP HANA Cloud, data lake, we created a virtual table in
our instance T2: We have created a table VT_TLOG_F_H that is pointing to the table TLOG_F_H in the
connected SAP HANA Cloud, data lake. To keep our tables organized, we first created a schema for this
virtual table:
8. To then create the virtual table VT_TLOG_F_H in the schema VT_datalake_T2, we clicked on Remote
9. There, we clicked on the remote source SYSRDL#CG_Source (the SAP HANA Cloud, data lake), selected
the schema SYSRDL#CG, selected the table TLOG_F_H and clicked on Create Virtual Object(s).
10. In the wizard to create the virtual object, we named it VT_TLOG_F_H (VT for virtual table) and selected the
13
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
What data will we be working with and what do the table names indicate?
We will use sample data with sales data of different items that have been sold in the years 2016-2020. The
three tables we have created will later be populated with data from different date ranges. The table names
indicate what year the sales data is coming from:
TLOG_F_C: C=Current; this table that is located in your SAP HANA Cloud, HANA database trial instance T1
will contain the data from 2020
TLOG_F_O: O=Online; this table that is located in our SAP HANA Cloud, HANA database instance T2 will
contain the data from 2019
TLOG_F_H: H=History; this table that is located in the SAP HANA Cloud, data lake that is connected to our
instance T2 will contain the data from before 2019
With that, our preparations are complete, and you can now connect to the database T2 using the credentials of the
user T2 and access the tables we have created.
14
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
The following steps are for you to follow along with your own trial account, which we will refer to as "T1".
2. Open your trial instance in the SAP HANA Database Explorer. You can get there via several ways:
· In BTP Cockpit, navigate to your trial instance and click on Actions at the bottom right of your instance tile.
Select Execute SQL and explore objects in SAP HANA Database Explorer.
· In SAP HANA Cloud Central, where you started your instance, click on the three dots in the column Actions
and select Open SAP HANA Database Explorer.
3. In your catalog, right-click on the database connection of your trial instance and select Open SQL Console.
Create users
To avoid working with the powerful user DBADMIN, we will first create two users with fewer authorizations:
1. A user UPS, who will be used in a user-provided service later. Paste this code to your SQL console and
execute it:
2. And a user T1, who will do all the setup. To do that, paste and execute this statement next:
3. For the user T1 to be able to do all the necessary steps, we need to grant this user the privileges to create
schemas and remote sources as well as the role admin privilege. Execute these three statements next:
grant create schema to T1;
grant create remote source to T1;
grant role admin to T1;
15
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
1. Next, we will create a PSE (personal security environment) and name it FOR_REMOTE_SOURCES. This PSE
will store your certificates for remote source connections. Execute this statement in your SQL console:
2. Create a certificate for the SAP HANA Cloud connection using the certificate string provided and add the
-----BEGIN CERTIFICATE-----
MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=-----END CERTIFICATE-----'
3. To add this certificate to the PSE, you need to find the certificate ID of this certificate. You can get it by
5. Using the ALTER PSE command, add the certificate and insert the certificate ID you have just copied.
6. Set the PSE for the purpose remote sources using this next statement:
Now your certificate store will use this certificate whenever you establish a remote source connection.
16
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
2. In the prompt that opens, enter the credentials of the user T1.
Username: T1
Password: DnATBG!1
17
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
3. We recommend that you enter T1 (T1) in the field Display Name of this new connection to easier distinguish
4. With a right-click on this database connection, open a SQL console. You will see at the top bar that you are
5. We will create a virtual table on our remote source next. Before we do that, we will create the schema
VT_DATALAKE_T1. This is where the virtual table we will create next in your own instance T1 will be placed
18
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
Now, we will create a remote source to the SAP HANA Cloud, HANA database instance T2 and call this remote
source connection T2.
1. In your catalog under the database connection of user T1, click on Remote Sources and select Add Remote
2. In the field Server enter the SQL endpoint of our instance T2:
a6a3218c-472b-4e6c-9be5-d2db786bc8fd.hana.prod-jp10.hanacloud.ondemand.com
Username: T2
Password: DnATBG!1
6. Click on Create.
19
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
For you to access the table in the SAP HANA Cloud, data lake, you next need to create a virtual table that is pointing
to the virtual table VT_TLOG_F_H in T2, which is pointing to the table TLOG_F_H in the SAP HANA Cloud, data lake.
1. Click on Remote Sources in your catalog. There you will now see the remote source T2 you have just
created.
2. Click on the Remote Source T2. A new panel will open on the right side of the screen.
3. Select the schema VT_DATALAKE_T2 in the dropdown menu and click on Search. You should now see the
4. Click on the check box on the left to select it and click on Create Virtual Objects.
5. A wizard will open. Enter the object name VT_TLOG_F_H, select the schema VT_DATALAKE_T1 from the
6. Your virtual table is now created that you can find in your catalog under tables.
20
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
To be able to work with this new virtual table VT_TLOG_F_H, we need to grant privileges to our application users
and object owners of projects in SAP Business Application Studio.
1. Close the remote source window and go back to the SQL console of the connection with the user T1.
2. First, the user UPS should get privileges to INSERT; UPDATE; DELETE and SELECT on the table
VT_TLOG_F_H. For that, we first need to create a role, which we will call LOAD_VT_TLOG_F_H, assign the
The system generated object owner user should get SELECT privileges on the table with grant option. For that, we
will create another role, which we will call SELECT_ON_VT_TLOG_F_H_WITH_GRANT, assign the privilege to this
role and assign the role to a role that is assigned to all object owners of Business Application Studio projects per
default:
4. The system generated application users should get SELECT privileges without grant option. Similarly, we
will create a role named SELECT_ON_VT_TLOG_F_H, assign the privilege to this role and grant the role to
the role “RT_DEFAULTS” that is assigned to application users of Business Application Studio users pers
default.
21
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
6. Lastly, the user UPS is assigned a role that allows the creation of virtual tables on the remote source. We will
call this role createVTOnT2. As before, paste and execute the statement:
create role "createVTOnT2";
grant create virtual table on remote source T2 to "createVTOnT2";
grant "createVTOnT2" to UPS with admin option;
2. After downloading the zip file, unpack it to a directory on your local machine.
7. In the drop-down menu Select Import Objects From, select Local Computer
8. In the field Local Archive (*tar.gz), click on Browse… and select the file from the directory it has been
downloaded to.
22
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
9. Click on Open and wait for the metadata to load. Once the upload is finished, you should see the Catalog
10. You don’t have to check any of the other boxes, simply click on Import.
Create a role that provides access to this data and grant it to the user UPS
1. Lastly, to access this imported data later, we need assign one last role to the database user UPS.
2. We will call this role SELECT_ON_BASKETANALYSIS_ALL and grant this role SELECT privileges to this role.
With that, we are finished preparing on the SAP HANA Database Explorer side and are ready to switch to SAP
Business Application Studio.
23
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
1. Open SAP Business Application Studio (if you have not bookmarked it last session, go to SAP BTP cockpit,
click on Trial Home at the top bar and under Quick Tool Access, you will find SAP Business Application
Studio).
2. Start your development space from session 1 if you have not done so prior to this session.
3. Enter your workspace once it is running by clicking on the name of the dev space.
6. In the first step of the wizard (Add Basic Information), enter a name for your project on the Project Name
7. In the next step of the wizard (Set Basic Properties), keep db as a default name in the Module Name field
8. In the next step of the wizard (Set Database Information), leave the optional fields Namespace and Schema
9. In the dropdown menu SAP HANA Database Version, select HANA Cloud.
10. In the field Bind the database module to a Cloud Foundry service instance?, select Yes and click on Next.
11. In the next step of the wizard (Bind to HDI Container service), you need to provide your credentials to bind
this project to an HDI container unless the credentials are still saved in your browser cache. Click on the
login icon and your organization and space will be filled automatically.
12. In the field Create a new HDI service instance?, select Yes.
13. In the next field you can keep the default service instance name.
14. Select Yes in the last field as well to use the default database instance of the Cloud Foundry space.
24
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
16. In your workspace, click on the db folder, there, select the src folder.
17. Press F1 to open the Find Command prompt at the top of the screen.
18. Enter HANA and select Create SAP HANA Database Artifact.
19. Click on the folder icon in the field Choose path where you want to create the artifact.
20. A wizard will open in which you can select the directory for the calculation view.
21. Click on home, user, projects, your project name (Federation), db and then src and click on Open.
23. In the Artifact Name field, give a name to your file (Federation).
25
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
26. The file will appear on the left panel in the src folder.
27. Click on the calculation view file in the src folder to open the calculation view editor.
28. Click on the icon on the left side and drag it to the editor to add a union node.
29. Click on the node Union_1 to see the editing options of this node.
26
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
You see here that the wizard can only add objects to the calculation view that are already in the project, there is
no option to select External Services, since there are no database connections in this development project yet.
Since we want to use the objects from the HDI container from session 1, we first need to connect this project to
the project from session 1.
Database Connections.
2. Move your cursor to the line Database Connections and click on the plus icon.
3. In the wizard that opens, in the field Select Connection type, select Existing HDI Container
4. In the field Select SAP HANA HDI Service instance, select the name of the container you have created in
session 1 (HANACLOUD_WORKSHOP2).
5. Click on Add at the bottom of the screen and the connection will be established
6. A message will appear on the bottom right corner telling you the connection has been created, and the
27
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
3. Select the service connection you have just created from the drop down menu.
4. On the search bar, enter ** to search for all objects in this database connection. You should see there the
5. Select the table TLOG_F_C from the list by clicking on the check box on the left.
7. In the next step of this wizard, check the options Synonym for HDI Container and Generate .hdbgrants File.
11. Once this step is finished, you will see in your src folder that the hdbgrants and hdbsynonym files have been
created.
28
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
1. Click on the hdbgrants file that was created while the service connection was established.
2. The code editor will open. There, you can see the authorizations involving the two roles specified in the
previous step.
We need to slightly adjust the hdbgrants file to also authorize us to load data into the table. Adjust the hdbgrants file
as follows:
4. Enter "LOAD_TLOG_F_C".
5. Do the same below, add a comma, line break and "LOAD_TLOG_F_C" after the line that contains
"SELECT_ON_TLOG_F_C_WITH_GRANT#".Here you can see the complete adjusted code (adjusted parts
marked red), which you can also simply copy and paste in the file replacing the previous code (if you do
that, make sure the service connection name matches the one you chose in your project):
{
"<enter connection name, e.g. HANACLOUD-WORKSHOP2-hdidb-ws-wk598>": {
"object_owner": {
"container_roles": [
"SELECT_ON_TLOG_F_C_WITH_GRANT#",
"LOAD_TLOG_F_C"
]
},
"application_user": {
"container_roles": [
"SELECT_ON_TLOG_F_C",
"LOAD_TLOG_F_C"
]
}
}
}
6. Lastly, click on the rocket icon at the top right corner to deploy this file. Alternatively, you can deploy it
Now the object owner and application user can insert data into this table. Since later we will also load data into table
TLOG_F_O, we will next create a connection to a hdi container. This means we need to create a user-provided
service connection that will allow us to do so.
Since the workshop has aired, there was a change introduced in this step. You can now directly choose to
create a user-provided service using the deployment target container database information. By default, the
option Use target container database information should be selected for you, which you can leave selected
for this example. If you do need to change host and port information, you must select the option Connect to
database.
1. On the left, in the SAP HANA Projects panel, click on the plus icon on Database Connections.
2. In the Select Connection Type field, click on Create user-provided service instance.
4. To establish the connection, you need the SQL endpoint of your own trial instance T1.
5. Open SAP BTP cockpit or SAP HANA Cloud Central and navigate to your SAP HANA Cloud, HANA database
instance. On your SAP HANA Cloud instance tile/line, click on the three dots/Actions and select Copy SQL
endpoint.
30
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
6. Paste it in the field Enter host name and remove the last four characters(":443")
7. In the field Enter host port, enter the three last digits from the host name (443)
9. In the field Enter Password, enter the password you gave this user earlier: DnATBG!1
31
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
1. In your project folder, right click on the src folder and select New File.
Info: By adding the suffix ".hdbgrants", SAP Business Application Studio will automatically recognize that
this file is an hdbgrants file, similar to when you create an SAP HANA Database Artifact via the Find
Command prompt. The same applies for all different kinds of SAP HANA Database Artifacts, like
.hdbsynonym, .hdbtable, .hdbcalculationview, .hdbanalyticprivilege, and so on.
3. The file will appear on the left panel, click on it to open the code editor.
{
"UPS": {
"object_owner": {
"roles": [
"SELECT_ON_BASKETANALYSISDATA_ALL",
"LOAD_VT_TLOG_F_H",
"createVTOnT2"
]
}
,
"application_user": {
"roles": [
"SELECT_ON_BASKETANALYSISDATA_ALL",
"LOAD_VT_TLOG_F_H",
"createVTOnT2"
]
}
}
}
5. This code will grant the roles specified to the application users and object owners.
6. Click on the rocket icon in the top right corner or in the SAP HANA Projects panel to deploy this file.
32
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
Create synonyms
To be able to add objects to the calculation view that are not in the project, these objects need to be represented by
.hdbsynonyms, which we will create next.
2. Create new SAP HANA Database Artifact by either pressing F1 and selecting SAP HANA: Create SAP HANA
Database artifacts and naming this artifact loading and select the artifact enter synonym. Or by right
clicking on the src folder, selecting New File and naming it loading.hdbsynonym.
3. Right click on the file and select Open with Synonym Editor.
8. In the same way, add a second synonym and name it S_VT_DL. For the Object Name field, enter
9. Click on the rocket icon on the top right corner to deploy the synonyms
Now you are ready to create the flowgraph that will load data from the sample dataset you imported in SAP HANA
Database Explorer and write it into the different tables in your own trial instance T1, our instance T2 and the SAP
HANA Cloud, data lake.
33
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
CREATING A FLOWGRAPH
In this section, you will create your own flowgraph first to load data from the dataset BASKETANALYSIS_ALL to
your table TLOG_F_C. After that, we will show you for reference how we will also write data into the tables in our
own SAP HANA Cloud, HANA database T2 and its corresponding SAP HANA Cloud, data lake. You will then be able
to connect to these tables and read the data in your calculation view.
1. Click on the src folder in your project and press F1 to open the find command prompt.
2. Enter HANA and select SAP HANA: Create SAP HANA Database artifacts.
5. The file will appear on the left panel. Click on it to open the flowgraph editor.
6. Click on the plus icon on the left side of the Flowgraph editor. A menu will open.
34
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
7. Click on Data Source and move your cursor to the white canvas and click to place the Data Source. A Data
35
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
10. A wizard will open to select the object for your data source
11. Click on the drop-down menu External Services, where you should see the HDI container connection and
36
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
15. Click on the plus icon on the Terminal and select Projection and drag it to the canvas.
16. Connect the Data Source box and the Projection box: Click on the arrow icon on the S_COMBINED tile and
37
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
19. Enter year("OrderDate")=2020 to select only the data from 2020 to be loaded into your data target.
38
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
22. Click on the plus icon to now add a Data Target. Click on Data Target and move it to the canvas.
25. In the Search field, enter TLOG_F_C. Click on it and then click on Finish.
39
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
27. Now connect the Projection and the Data Target: Click on the OUT field on the Projection tile and drag it to
28. And with that the flowgraph is complete. Click on the rocket icon in the top right corner of the screen or
29. Before you execute this flowgraph, you can have a look at the table in your HDI container.
Preview the data in the SAP HANA Database Explorer and execute the flowgraph
1. In the SAP HANA PROJECTS panel, click on the HDI container icon on the level of your project.
2. The SAP HANA Database Explorer will open in a new tab with the HDI container connection already open in
the catalog.
4. Right click on it and select Open Data and you will see that the table is still empty.
40
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
6. In the flowgraph editor, click on Execute in the top left corner to have this dataflow executed on your table.
7. A prompt will open to confirm that you want to execute the latest build of this flowgraph. Select OK.
8. Switch back to the tab with SAP HANA Database Explorer where you opened the data of the table
TLOG_F_C.
41
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
Now, there is only the data from 2020 available as the data from the other HANA Cloud instance and its data lake
have not yet been loaded into the tables and have not been added to the view. We will now also fill the other tables
with data.
Before that, we need to prepare one more object in our project that points to the remote table TLOG_F_O.
4. Enter HANA and select SAP HANA: Create SAP HANA Database artifacts.
5. In the field Choose path where you want to create the artifact, click on the folder icon and navigate to the
7. Click on Create.
42
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
9. In the step Remote Source Selection, select the remote source T2 and click on Next.
10. In the step Remote Object Selection, from the Schema dropdown, select the schema T2.
11. Click on Search, which will show you the object TLOG_F_O in the schema T2. Select it and click on Next.
43
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
12. In the next step (Virtual Object Naming), enter VT_TLOG_F_O in the Object Name field and click on Finish to
13. In the SAP HANA PROJECTS panel, in the src folder of your project, you can now see this new object. Click
on the rocket icon next to the table or on the project level to build the virtual table.
14. The virtual table is now deployed to your hdi container. This was possible because of the hdbgrants files we
have created that authorizes the object owner to create virtual tables on remote source T2.
44
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
You do not have to follow the steps in this section; they are only for your reference to understand how the
flowgraph can be used to load data into remote sources as well. Once we have completed these steps, you
will be able to load the data from our instance via the connections you have made earlier.
1. First, we will show you how we will load data from the BASKETANALYSIS_ALL table to our table in the SAP
HANA Cloud, HANA database T2 and the SAP HANA Cloud, data lake.
4. As a Data Source we add from the UPS connection the synonym S_COMBINED, which represents the
source BASKETANALYSISDATA_ALL.
5. Next, we add a Projection to the flowgraph and connect it to the Data Source.
45
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
8. As target we specify VT_TLOG_F_O, the virtual table we have just created. Now the data from 2019 will be
loaded into the virtual table VT_TLOG_F_O and the table TLOG_F_O in instance T2 respectively.
9. Next, we want to load the data from before 2019 to the SAP HANA Cloud, data lake connected to the SAP
10. To add a different filter for a different data target, we place another Projection in the flowgraph, which we
46
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
12. We then add a second Data Target: the synonym S_VT_DL, which is representing the table VT_TLOG_F_H.
13. We connect the second Projection and this Data Target and then deploy and execute the flowgraph.
Now you know how we managed to use the flowgraph to write data from a table in our development project into the
tables in the remote source SAP HANA Cloud, HANA database T2 and the SAP HANA Cloud, data lake.
47
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
These following steps you can again follow along with your own instance and development project.
Since you have created a remote source and virtual tables in your own instance T1, the data we have just loaded to
the table in the SAP HANA Cloud, HANA database T2 and the SAP HANA Cloud, data lake will now be accessible to
you as well.
1. Switch back to the SAP HANA Database Explorer with the connection of your HDI container.
2. In the catalog, click on Tables and right click on the table VT_TLOG_F_O.
3. Select Open Data. You will now see the data from 2019 in this table.
5. Right click on S_VT_DL and select Open Data. There you will now see the data from before 2019.
48
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
5. In the tab Mapping on the left side under the field Data Sources, double click on com.sap::TLOG_F_C. This
will automatically map all columns from the Data Sources to the respective Output columns. Alternatively,
you can click on the Auto Map by Name icon on the right of the icon bar at the top.
49
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
6. Connect the Union node to the Aggregation node by clicking on the arrow icon at the union node and
8. Under Mapping, in the Data Source column, double click on Union_1 on the left side to automatically map all
9. Double click on the Semantics Node and in the panel that opens, click on the tab Columns.
10. There, scroll down to the column OrderYear and select it.
11. Click on the Attribute icon at the top bar to change the column type from measure to attribute. This
corrects the default assumption that integer columns are treated as measures.
12. Click on the on the rocket icon, on the top right corner to deploy the calculation view.
50
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
connection.
3. Right click on the Column View you have just created (Federation) and select Open Data.
4. In the Analysis tab of the data preview, we will create a diagram to quickly look at the data.
5. Under Available Columns, click on ItemPrice and drag and drop it on the Value Axis field
6. Under Available Columns, click on OrderYear and drag and drop on the Label Axis column.
7. In the diagram, you can see data from the year 2020, as the only table we added to the calculation view was
TLOG_F_C, the table that we loaded the data from 2020 to with the flowgraph. We will now add the other
51
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
1. Switch back to SAP Business Application Studio and go to the calculation view.
4. Search for the synonym S_VT_DL, select it from the list and click on Finish.
5. In the Mapping tab of the Union Node, select this source and click on the Auto Map by Name icon at the
52
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
7. Switch back to the SAP HANA Database Explorer and go to the diagram you have created in the previous
step.
9. Now you will also see the data from the years before 2019 which have been loaded to the table in the SAP
10. Switch back to SAP Business Application Studio and go to the calculation view.
11. Click on the Union node and click on the plus icon.
12. In the Find Data Sources wizard, search for the table VT_TLOG_F_O.
53
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
14. In the same manner as with the table in the SAP HANA Cloud, data lake, click on the Union Node, navigate
to the Mapping tab, and click on the Auto Map by Name icon at the top bar to map all source columns to
15. Click on the rocket icon to deploy the updated calculation view.
18. Now you will also see the data from the year 2019.
54
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
19. In session 3, we will use different techniques to improve query performance. For that, we will use a
20. The reference query we will use will be based on this data preview.
21. So, click on the SQL button on the top right corner of the diagram.
22. A window will open with the SELECT statement that queries the same data sources
23. Copy this statement to your clipboard or your notes for the next session.
24. In your catalog, right click on your database connection and select Open SQL Console.
25. Paste the statement to this console. When you log back in for session 3, it should still be saved.
55
SAP HANA Cloud Workshop Series | Creating database objects in SAP HANA Cloud with SAP Business Application Studio
Now you know how to build up a federated scenario to use multiple sources, and how to create flowgraphs and
calculation views with SAP Business Application Studio in SAP HANA Cloud.
In the next session, you will learn how to improve calculation views with union pruning, handle analytic privileges
and use caching for efficient queries.
56