Skip to Content
Technical Articles

Getting Started with SAP HANA Cloud IV | Cloud Foundry

With this blog series we provide an update with the latest information on getting started with SAP HANA Cloud on the SAP Cloud Platform.

  • Blog I – About SAP HANA Cloud with some background information and references.
  • Blog II – Creating an instance, connecting clients, sample app, and working with HDI containers.
  • Blog III – Connecting SAP Analytics Cloud using the HANA Analytics Adapter.
  • Blog IV – Cloud Foundry space travel, working with multiple instances, and defining schema names.
  • Blog V – Data masking and data anonymization
  • Blog VI – Predictive Analysis Library (PAL) and Automated Predictive Library (APL)
  • Blog VII – Remote data access (multicloud) using remote sources and virtual tables

Any good? Post a comment, share on social media, and/or give a like. Thanks!

For more information about the free trial, see

/wp-content/uploads/2016/02/sapnwabline_885687.png

Hands-On Video Tutorials

Chief partner engineer, Philip MUGGLESTONE just updated his SAP HANA Cloud playlist on the SAP HANA Academy YouTube channel with three short new videos covering space travel for SAP HANA Cloud instances or instance sharing, how to handle multiple instances in a single space, and to define explicit schema names for HDI containers.

In this blog, you will find the videos embedded with some additional information and resources.

You can watch the four video tutorials in about 30 minutes. What you get back is

  • How to access an SAP HANA Cloud instance from a different Cloud Foundry spaces and/or orgs
  • How to set the database ID of an SAP HANA Cloud instance when creating HDI container service instances
  • How to explicitly set the schema name when creating HDI container service instances
  • How to set the SAP HANA Cloud database ID and/or schema when creating multi-target applications
  • How to configure intra-HDI container access (from one container to another container)

We created the SAP HANA Cloud instance and explained how to work with HDI containers and the SAP Business Application Studio in the previous blogs, so make sure to read these first. To bookmark the playlist on YouTube, go to > SAP HANA Cloud

Ready for lift-off?

/wp-content/uploads/2016/02/sapnwabline_885687.png

Instance Sharing

In this tutorial, we discover how to access an SAP HANA Cloud instance from another Cloud Foundry space or organisation.

To access an SAP HANA Cloud instance from another Cloud Foundry space or even organisation, we need to create a mapping for the instance to the relevant Org and Space ID.

Across organisations, the cloud provider and region needs to be the same. If no space is selected, the mapping applies to all spaces.

Subsequently, we can create, for example, an instance of SAP HANA Schemas & HDI Container service (plan: hdi-shared) in our SAP. HANA Cloud database.

For the documentation, see

/wp-content/uploads/2016/02/sapnwabline_885687.png

Multiple Instances

In this video we discover how we can use the database ID when creating an HDI service instance or MTA application in case multiple instances are running in a single Cloud Foundry space.

In case your space contains multiple SAP HANA Cloud instances, you need to specify the database ID as parameter in JSON format when creating a service instance of the HDI container.

The cf command equivalent is

# connect
cf l
# target the right space
cf t -s dev
# list the available services
cf s
# get the GUID of the service 
cf service <service_name> --guid

# target the right space
cf t -s test
# create an HDI service instance specifying GUID 
cf create-service hana hdi-shared <name> -c '{"database_id":"<GUID>"}'

On Windows, escape the double quote characters

cf create-service hana hdi-shared <name> -c '{\"database_id\":\"<GUID>\"}'

The database ID is also used used as parameter in the mta.yaml file of the db target of a multi-target application (MTA). Below an example of the configuration using the SAP Business Application Studio.

For the documentation, see

/wp-content/uploads/2016/02/sapnwabline_885687.png

Explicit Schema Names

In this video tutorial, we discover how to set the schema name of an HDI container explicitly. The alternative and default value is a unique GUID.

When creating the HDI service instance, we can specify the schema as parameter in JSON format. The schema name must be unique in the database.

The service key displays the new schema value and is also used as prefix for the design time (DT) and runtime (RT) users.

When connecting we can now use a more user-friendly identifier.

jdbc:sap://12345-6789.hana.prod-eu10.hanacloud.ondemand.com:443?
encrypt=true&validateCertificate=true
&currentschema=MYSCHEMA"

Using the command line, specify the schema as parameter in JSON format.

cf create-service hana hdi-shared <name> -c '{"schema":"MYSCHEMA"}'

When creating a multi-target application. set the parameter in the resource section for the HDI container.

/wp-content/uploads/2016/02/sapnwabline_885687.png

Configure JWT Trust

In this video tutorial, we cover how to configure the trust relationship between your Cloud Foundry subaccount and the SAP HANA Cloud instance. This is required, for example, when a Node.js application needs to access an HDI container.

Source code: github.com/saphanaacademy/SAPHANACloud/blob/master/trust.txt

[0:00] – Introduction

[0:45] – 500 Internal Server Error returned when trust is not configured

[1:00] – Log message: the predefined session variable cannot be set via SET command XS_APPLICATION USER

[1:20] – open Database Explorer. The first four queries verify no JWT configuration has been configured yet

SELECT * FROM PSES WHERE PURPOSE = 'JWT';
SELECT * FROM CERTIFICATES;
SELECT * FROM PSE_CERTIFICATES;
SELECT * FROM JWT_PROVIDERS;

[2:45] – construct the JWT trust URL

https://<subdomain>.authentication.eu10.hana.ondemand.com/sap/trust/jwt

[3:20] – create certificate

CREATE certificate FROM '-----BEGIN CERTIFICATE-(...)-END CERTIFICATE-----';
CALL SYSTEM.CREATE_JWT_PROVIDER
('JWTPROVIDER1', 
 'https://yoursubaccountdomain.authentication.<region>.hana.ondemand.com/oauth/token', 
 'user_name', true);

[3:50] – get certificate ID and create PSE

CREATE pse PSE1;
ALTER pse PSE1 ADD certificate <certificate_id>;
CALL SYSTEM.SET_PSE_PURPOSE
 ('PSE1', 'JWT', ARRAY('JWTPROVIDER1'));

[4:30] – app returns data

/wp-content/uploads/2016/02/sapnwabline_885687.png

Intra-HDI Container Access

In this video tutorial, we learn how to configure access from one HDI container to another within the same Cloud Foundry Org and Space.

The source code for this project is in the SAP HANA GitHub repository

0:40 – Use git clone to import this into SAP Business Application Studio (or your preferred IDE).

1:30 – The protagonists of this tutorial are the applications scpapps (source) and myappssyn (target) and we start with defining two design-time role definitions (.hdbrole):

  • a standard role with read access to the sales table in the container
  • a privileged role, identical to the standard but with grant option 

2:50 – Build and deploy the MTAR to your Cloud Foundry space.

3:40 – This results in an app, we can access in a browser to display data from the sales table.

4:10 – We can view the same data when we connect to the HDI container in the Database Explorer.

5:00 – The mta.yaml configuration file for our second application specifies the TARGET_CONTAINER property and references an existing service name, the name of the HDI container that was created when we deployed the myapphana app.

6:11 – The target app includes sales.hdbgrants which assigns the two roles to the technical users:

  • with-grant option (_g#) to the object owner
  • regular role to the runtime user

6:55 – The target app also includes the src/sales.hdbsynonym and cfg/sales.hdbsynonymconfig artifacts specifying myapphana as the source object.

8:15 – The query in server.js selects from the synonym.

app.get('/srv/sales', function (req, res) {
    req.db.exec('SELECT * FROM "myappsyn.db::sales"', 
    function (err, results)
   (...) }

8:30 – Build and deploy the application.

9:07 – Open the myappsyn app and view the sales data stored in the HDI container from myapphana.

9:28 – Add the HDI container from myappsyn to Database Explorer and view the sales data via the synonym.

10:00 – In case the service name (in our example myapphana-hdi) is not known when you develop the application, you can use the file mta-config.mtaext to provide this information at deploy time.

For the documentation, see the topics in the SAP HANA Developer Guide for SAP HANA XS Advanced Model

/wp-content/uploads/2016/02/sapnwabline_885687.png

Share and Connect

Enjoyed the blog? Post a comment, share on social media, and/or give a like. Thanks!

If you would like to receive updates, connect with me on

Best,

Denys van Kempen

/wp-content/uploads/2016/02/sapnwabline_885687.png

 

10 Comments
You must be Logged on to comment or reply to a post.
  • Hi Denys van Kempen,

    I’ve tried to use Hana Cloud Service with WebIDE by setting the HDI container parameter with database_id. I got the GUID via command line, but the deployment process is always unable to find the database id in my org/space.

    I’ve tried to create the hdi container manually via CLI, but I got the same error.

    Are there any additional settings in the MTA to make this work on a trial account?

    Best regards,
    Ivan

  • Hi Ivan,

    [UPDATED]

    As of July 12, we now have two entitlements for HDI

    • SAP HANA schemas & HDI containers (trial): plan = hanatrial >> SAP HANA Service
    • SAP HANA schemas & HDI containers: plan = hana >> SAP HANA Cloud

     

     

     

    /
  • Hi Denys van Kempen,

     

    When iam trying to add my HANA Cloud instance database_id while creating HDI shared containers iam receiving the following message:

    Unable to create service instance. We are sorry, but we have encountered an internal error. If the problem persists, please create a support ticket.

    Service broker error: Service broker hana-broker-trial failed with: Can not create service instance ‘SFLIGHT’: There is no database with database_id ‘xxxxxxxxxxxxxx’ in space ‘dev’ within organization ‘7cbbca8dtrial’. Check the database_id. “
    But my Hana Cloud instance is running in the same dev space as my hdi- shared containers.
    hana%20instance%20running%20in%20dev%20space
    Thank you,
    Shiyam
    /
    hana%20instance%20running%20in%20dev%20space
  • Hi Denys van Kempen,

    I have again tried and still it is throwing the same error, my new hdi-shared instance is not able to find my hana cloud instances, though my hana cloud instance is running on the same dev space.

    hdi%20instance%20error

     

    And also the hdi instances created by building a hana database module by selecting (hana cloud as version) is also not pointing to my hana cloud instances. I could see the host in service key of the hdi instance is still pointing to “”host”: “zeus.hana.prod.us-east-1.whitney.dbaas.ondemand.com”,”

    I tried deleting and recreating the hana cloud instances and also tried deleting and re creating the entire trial account multiple times, but no luck.

    Thank you for the help

    shiyam

    /
    hdi%20instance%20error
  • Hi Shiyam,

    Thanks for sharing. There are currently two entitlements for HDI.

    • Add a service plan for SAP Schemas & HDI Containers
    • Create a SAP HANA Cloud instance
    • Create an instance of the SAP Schemas & HDI Containers service
    • (optionally) Create a service key – this displays the URL

    As long as the SAP HANA Service is still available there also needs to be a service for schema and HDI. It would be helpful, of course, if this was clearly indicated in the name.

    Solves your issue?