Quantcast
Channel: SCN : Blog List - All Communities
Viewing all articles
Browse latest Browse all 2548

XS Advanced features: Using Synonyms; Using non-HDI container schema objects in HDI container.

$
0
0

This blog will give you information on how to use objects of a non-HDI container or stand-alone schema into your container.


A word about HDI Containers


As we enter the world of XS Advanced, we come across many new terms and one of them is "HDI container".

You can think of it as a database schema. It abstracts the actual physical schema and provides schema-less development. All the objects you create will sit in a container. You can read more about them in the blog written by Thomas Jung. Please visit http://scn.sap.com/community/developer-center/hana/blog/2015/12/08/sap-hana-sps-11-new-developer-features-hdi

 

The key points that we need to emphasize while working with the HDI containers are:

  • A database schema and a technical user also gets created in the HANA database for every container. All the run time objects from the container like tables, views, procedures etc. sit in this schema and not in the schema bind to your database user.
  • All the database object definitions and access logic has to be written in a schema-free way.
  • Only local object access is allowed. It means that you can only access the objects local to your container. You can also access the objects of other containers and non-HDI container schemas (foreign schemas) but via synonymsas long as the technical user of the HDI schema has been granted access to this foreign schema.

 

Creating Synonyms

 

Now you will be looking at an example of creating a synonym for the objects of a non-HDI container schema (foreign schema) in your container.

This example is based on SPS 12 and uses both XS command line tool and SAP Web IDE for SAP HANA (XS Advanced) tool.

 

Prerequisites:

  • You should have a database user who should be able to access XSA Web IDE tool.
  • Your database user should have the authorization (WITH GRANT OPTION) on the foreign schema.

 

Let's start with the example step by step.

 

Create a user provided service.

You have to create a user provide service for your foreign schema. Open XSA client tools and login using your user by issuing 'xs login' command.

Now create user service by issuing 'xs create-user-provided-service' or 'xs cups' command.

You can use the following syntax:

xs cups <service-name> -p "{\"host\":\"<host-name\",\"port\":\"<port-number>\",\"user\":\"<username>\",\"password\":\"<password>\",\"driver\":\"com.sap.db.jdbc.Driver\",\"tags\":[\"hana\"] , \"schema\":\"<foreign schema name>\" }"

 

 

Modifying mta.yaml file.

You have to correctly configure all services including the user provided service in the mta.yaml file. This allows using the user provided service within the project.

 

Add an entry of the user provided service you created in 'resources' section of mta.yaml file. Use the below sample code as a reference.

mta1.JPG

Figure 1: Entry of user provided service in mta.yaml file example

 

Also, add a dependency of this service in HDB module of your project. Use the below sample code as a reference.

mta2.JPG

Figure 2: Service dependency in HDB module (mta.yaml file example)



Creating .hdbsynonymgrantor file.

This file specifies the necessary privileges to access external tables. Open XSA Web IDE and under HDB module of your project create a new folder with name 'cfg', just like the 'src' folder, its name is special. This tells the HDI deployer that this folder containes configuration files and treats them appropriately.

Create your .hdbsynonymgrantor file under this folder. Sample content of this file might be:grantor_file.JPG

Figure 3: .hdbsynonymgrantor file example



Creating synonym for external object

Create a .hdbsynonym file in 'src' folder of your HDB module. In one .hdbsynonym file you can define multiple synonyms to be used in your project.

Please use the below code sample as your reference for creating synonyms.

synonym.JPG

Figure 4: .hdbsynonym file example


Now, you should be able to use those external tables in your container using these synonyms.


Viewing all articles
Browse latest Browse all 2548

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>