How to use objects contained in a schema outside of your Web IDE Full-Stack project in SAP HANA Service
If you are working in Web IDE full-stack in a SAP HANA Service environment and you would like to consume objects that are not part of your project, you can achieve this with the following three steps:
- Connect with a service to the schema
- Assign the necessary authorizations to the technical users of your project
- Create synonyms pointing to the objects
All of these steps are described in an on-premise context for example in documetation or blog1, blog2. For a recent example that also includes loading data and accessing external schemas in the context of SAP HANA Service see blog3
In SAP HANA Service these are currently manual steps but graphical user interfaces are planned for the beginning of 2019. To make the start of modeling a bit easier the blog shows the steps of consuming objects outside of your project in SAP HANA Service. The example assumes that table “SalesOrderItem” in schema “DMM260” should be consumed in a Calculation View and that you create a user provided service “UPS” to this end.
1. Connect with a service to the schema
In the SPACE of your instance, select the option “User Provided Service” under Services
If a user provided service that fulfills your requirements does not already exist you can create it with button “New Instance”.
The following definition would create a user provided service called “UPS” that is based on a database user UPSUSER with password “secret1234”
“password”: ” secret1234″,
Make sure that the database user UPSUSER exists, has the authorization to GRANT SELECT WITH GRANT OPTION on table “SalesOrderItem”, and uses this password.
Next, you have to add the service to your project by including it in your .yaml file. To do so right-click on the .yaml file of your project and select “Open Code Editor”. Below is a simple yaml file. The changes due to the added user provided service named “UPS” are marked in bold:
– name: db
– name: hdi_db
– name: UPS
– name: hdi_db
– name: UPS
2. Assign the necessary authorizations to the technical users
Next you will need to create and build a hdbgrants file. This file should grant SELECT WITH GRANT OPTION on objects that are to be used in e.g., Calculation Views to the user “object_owner”. A simple SELECT is enough for the “application_user”. As best practice, these privileges should be granted via roles.
The roles “roleForApplicationUser” and “roleForObjectOwner” can be creates as SQL roles. Make sure that the database user behind the user provided service (UPSUSER) has been granted the authorization to grant these roles.
3. Create synonyms pointing to the objects
Finally, you need to create and build synonyms that point to the respective objects. The following description would create synonym “O1” pointing to table “SalesOrderItem” in schema “DMM260”:
“object”: ” SalesOrderItem “,
“schema”: ” DMM260″
You might want to use the .hdbsynonymconfig approach that is also detailed at the help portal to achieve more flexibility when addressing the source schema, e.g., using no fixed schema but fill the schema by the user provided service. This flexibility can come handy in a transport context.
With these steps you should now be able to use the object in e.g., your Calculation View. Simply select the object with the created synonym in the “Add Data Source” step of your Calculation View and press “Finish”