Skip to Content
Technical Articles

Simulating my shared Food HDI container

Last week in Las Vegas, I had the privilege of running a hands-on session on SAP HANA cloud-native development (DAT365) with Thomas Jung  and  John Astill .

The most valuable part of this are the opening talks that provide context, interesting demoes and interactions with other people as you learn your way into Cloud Foundry and HANA. However, if you couldn’t make it or if you want to do this again on your own, this blog post is for you.

 

Get a trial account in US East VA

I’m using the trial for HANA as a Service here. Why? Because ever since the HDI containers in US10 are created in an SPS04 HANA instance, I’ve been using it and abusing it, as in this other introductory tutorial… This works in HANA express, too.

So if you need help getting a trial account, you can follow these perfectly documented steps by  Marius ObertGet a Free Trial Account on SAP Cloud Platform .

If you already have a trial in EU10, you can transfer entitlements with these instructions.

Once you have your trial, Launch SAP Web IDE:

You will need to make sure the extension for SAP HANA Database Development is enabled. You find this from the Settings > Extensions.

Create a database project

One of the main things stopping you from completing the exercise yourself is a shared HDI container with data, that lives in a different space that you can’t see. This was on purpose, as I did not want to risk a curious person accidentally eating all the FOOD I loaded into that container.

You will create a small copy of this database for yourself and still configure cross-container access, but in the same space.

  1. In SAP Web IDE, right-click on your workspace and choose New > Project From Template.
  2. Choose SAP HANA Database Application. Click Next:

  1. Call the project FOOD
  2. Remove the namespace, call the schema FOOD, choose SPS04 and hit Finish

Edit the development descriptor (aka, mta.yaml)

This is everyone’s favorite: if you are not paying attention, you’ll get all sorts of errors.

  1. Click the resources tab
  2. Click + under Parameters
  3. Add service-name under Key and food-hdi under Value

  1. Save the file

  1. Go into the Code editor and make sure it looks like this, pay special attention to the highlighted parts:

Here is an explanation of what this file is doing:

The content of the file so far means that you have a database module called db (type hdb), that lives in a folder called db. This module has a single dependency, an HDI container.

This HDI container will be created automagically in the HANA database that a team of magicians upgraded for us. You are telling the HDI deployer that you want the name of your physical schema to start with FOOD (you will get a number added to that to allow for different physical versions of the same HDI container). You are also forcing the name of the service, because you will reference it later and don’t want the deployer to get too creative. This value will be assigned to hdi-container-name.

Build the database module

Easy, right-click on the db folder and choose Build

Give it a while. In the meantime, you can go back to the main landing page, enter your trial account, go into the trial and navigate into the space called dev.

You should see the food-hdi service there if everything went right in the build:

And success messages:

Create tables

Or import them. Go into this repository: https://github.com/SAP-samples/teched2019-hana-cloud-dat365-native-development/tree/data

And click Download Zip

Use the import wizard to Import it under db/src:

Like this:

You’ll get a warning about existing files, click Import.

You only want the data folder. So I just cut it out of the bigger folder, pasted it outside and deleted the rest.

Build the db module:

Once you get a successful message, you can right-click on the db module and go for Open HDI Container

You will see the works of the HANA Deployment Infrastructure here. How the schema and tables have been created for you:

Add roles in your container

These are the roles (in a folder called roles) that exist in the original container:

admin.hdbroles:

{
	"role":{
		"name": "admin",
		"schema_privileges": [{
		   "privileges": ["SELECT METADATA", 
		    			  "SELECT CDS METADATA", 
		    			  "SELECT", 
		    			  "INSERT", 
		    			  "EXECUTE", 
		    			  "DEBUG",
		    			  "CREATE TEMPORARY TABLE"
		   ]
		}]
	}

 

adminGrant.hdbrole

{
	"role":{
		"name": "adminGrant#",
		"schema_privileges": [{
		   "privileges_with_grant_option": ["SELECT METADATA", "SELECT CDS METADATA", "SELECT", "INSERT", "EXECUTE", "CREATE TEMPORARY TABLE" ]
		}]
	}
}

 

Configure cross-container access

You can now get started with the mission we created with Thomas: https://developers.sap.com/tutorials/hana-teched-dat365-native-development.html

When you get to step 7, configure cross-container access, the wiring in the mta.yaml file will be slightly different, because you will reference the exiting container called food-hdi, instead of the user-provided service that executes a procedure on my original shared container:

 

 

The rest of the instructions should remain the same.

 

On a personal note…

This is my last blog post as an SAP employee. It was a tough decision to leap into a new opportunity while having a dream job, but I am hoping to stay in touch.

I will continue to be active in my Twitter and LinkedIn accounts as well as my new/old profile in the SAP Community.

Cheers,

Lucia Subatin.

 

 

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