🎓beginner⏱20 min.SAP HANA Service For SAP BTPBeginnerSAP HANA
You will learn
โHow to create a plain schema, with a table and user to simulate a replicated schema
โHow to create a user-provided service to access a database in SAP HANA service for SAP BTP
โHow to grant permissions to the technical users in your HDI container to access the database This tutorial is meant to be an example of cross-container access. Simple data models and loading mechanisms were chosen to simulate a schema replicated using tools such as SAP Landscape Transformation or an ABAP schema. For more information on this process and additional syntax options, refer to the official documentation on SAP Help. If you are looking for the steps for an on-premise SAP HANA instance with XS Advanced, such as SAP HANA, express edition, refer to this tutorial.
This tutorial cannot be completed with a trial account.
Step 1Create a plain schema
โ
Connect to SAP Web IDE Full Stack and enter the Database Explorer. You will see your instance of the SAP HANA database.
If you cannot see the database, try entering the database explorer from the Database Cockpit and make sure the setting in Preferences->Database Explorer are set to the correct region.
DB Explorer
Use the following code to create a schema and a user. You will also create a simple table to use as an example for cross-container access.
You will create a SQL role and assign it to the user PLUSR with the permissions granted manually before. This user will be used for the connection between the HDI container and the plain schema, and will grant the role to the HDI container technical user.
You can see the SAP HANA service (a database instance, from which you access to the Database Cockpit) of service type hana-db and the HDI container of service type hana and plan hdi-shared listed in the service marketplace
ย schemaย
You can also see both connections in the Database Explorer
ย schema
Click on Tables. Right-click on the REGIONS table and select Import Data
Import data in SAP HANA
Browse for the file you have just downloaded. Keep PLAIN and REGIONS as the target and click Step 2
Import data in SAP HANA
Keep the default table mapping and click Step 3
Import data in SAP HANA
Click Show Import Summary
Import data in SAP HANA
Use Import Into Database to load the records
DB Explorer
You should see the wizard has imported 4 records
DB Explorer
Right-click on the table and choose Open Data to see the records loaded into the table.
Step 3Create a user-provided service
+
You now have a schema with a table and data in it. You have also created a user called PLUSR with permissions to perform basic operations on that schema. You will now create a user-provided service to access the schema through the user PLUSR from your Multi-Target Application.
Use Tools -> SAP Cloud Platform Cockpit to open the cockpit.
user provided service
Navigate to your Cloud Foundry account by going back to the Home
user provided service
Enter the Cloud Foundry subaccount and into the space in which you are deploying the application. Click User Provided Services and New Instance
user provided service
Call the service CC_ACCESS and use the code below in Credentials
You will now add the user-provided service as a dependency and configure it as part of a database module. You will also set the original HDI container as the default service for database artifacts.
Go back into SAP Web IDE Full-Stack. Open the file mta.yaml in the MTA Editor and use the + sign to add a resource.
DB Explorer
Call the service external_access of type org.cloudfoundry.existing-service.
Use the following key value pair under parameters.
key
Value
service-name
CC_ACCESS
Use the following key value pair as properties.
key
Value
ups-service-name
${service-name}
DB Explorer
Save the file.
Click on the Modules tab and add external_access in the Requires section.
DB Explorer
Use SERVICE-REPLACEMENTS as the value for Groups.
Name
Group
external_access
SERVICE-REPLACEMENTS
Use the following key-value pair as the properties of external_access
key
Value
key
external_access
service
~{ups-service-name}
Click on hdi_db and set the following key-value pair as properties
key
Value
TARGET_CONTAINER
~{hdi-container-name}
cross container access
Click Save
cross container access
If you switch to the Code Editor for the mta.yaml file, it should look similar to this:
MTA yaml
Step 5Grant permissions to the technical users
+
You will now create an artifact that grants access to the two technical users of your HDI container. These are not real users, but technical ones.
Alternatively, you can grant the same permissions to the user in the user-provided service, PLUSR, and create a separate grants file with them or a new role.
Here is an example for that .hdbgrants file
This procedure will show the session user name, the technical user (HDI object owner) executing the statement, the privilege (e.g., SELECT) and some flags starting with IS_MISSING. A TRUE value under one of those flags indicates missing authorizations.
Make sure the user in the user provided service has permissions for SELECT and SELECT METADATA with grant option.
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 9
1. Create a plain schema2. Load data3. Create a user-provided service4. Configure the service for access5. Grant permissions to the technical users6. OPTIONAL - Grant access to a remote source7. Create synonyms8. Create a view9. Troubleshooting insufficient privileges
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.