Skip to Content
Technical Articles

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:

  1. Connect with a service to the schema
  2. Assign the necessary authorizations to the technical users of your project
  3. Create synonyms pointing to the objects

 

All of these steps are described in an on-premise context for example in documetation or blog1blog2. 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”

{

“desc”: “example”,

“user”: “UPSUSER”,

“password”: ” secret1234″,

“tags”: [

“hana”

]

}

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:

ID: Demo
_schema-version: ‘2.1’
version: 0.0.1

modules:
– name: db
type: hdb
path: db
requires:
– name: hdi_db
  properties:
        TARGET_CONTAINER: ~{hdi-container-name}
       
    – name: UPS
      group: SERVICE_REPLACEMENTS

      properties:
        key: ServiceName_1
        service: ~{the-service-name}

resources:
– name: hdi_db
properties:
hdi-container-name: ${service-name}
type: com.sap.xs.hdi-container

 – name: UPS
   parameters:
      service-name: UPS
   properties:
      the-service-name: ${service-name}
   type: org.cloudfoundry.existing-service

 

 

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.

{
“UPS”: {
“object_owner”: {
“roles”: [
“roleForObjectOwner”
]
},
“application_user”: {
“roles”: [
“roleForApplicationUser”
]
}
}
}

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”:

{

“O1”: {

“target”: {

“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”

Be the first to leave a comment
You must be Logged on to comment or reply to a post.