Monday 7 October 2019

Simulating my shared Food HDI container

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 Obert :  Get 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:

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

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:

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

3. Call the project FOOD

4. Remove the namespace, call the schema FOOD, choose SPS04 and hit Finish

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

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

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

4. Save the file

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

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

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

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

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

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.

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

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

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

And success messages:

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

Create tables


And click Download Zip

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

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

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

Like this:

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

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:

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

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

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

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

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

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


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:

SAP HANA Tutorial and Materials, SAP HANA Learning, SAP HANA Study Materials, SAP HANA Online Exam

The rest of the instructions should remain the same.

No comments:

Post a Comment