Sitemap

SAP HANA Cloud, creating HANA Database project, using MTA for deployment

6 min readJun 13, 2021

--

SAP HANA Cloud is a fully managed in-memory cloud database as a service (DBaaS). Highly Elastic and low total cost of ownership as this is offered as cloud service.

In this blog, lets us see step by step process to create a new HANA database instance in SAP trial account, create a HANA database application using SAP Business Studio to include .hdbtable, create a new HDI Container service (a service that enables you to deploy database development artifacts to so-called containers. This service describes the deployed (run-time) state of SAP HANA database artifacts). Finally create a MTA (Multi Target Application) for our application which is a deliverable artifact, and can be used to deploy to any other CF account.

Pre-requisites

SAP BTP Trial account which can be registered from https://account.hana.ondemand.com/#/home/welcome

Using Business Application Studio.

Creating a SAP HANA database Instance

Navigate to default sub account (trial) and use the dev space which is provided by default. From left menu click on SAP HANA Cloud and then create a SAP HANA Database

Select the Org. and provide the password for DBADMIN

Next regarding the allowed connection, you can select Allow all IP address incase you are accessing this DB except BTP

We will see more on Data Lake feature of HANA Cloud in upcoming blogs, for now you need not change anything here, click on Create Instance.

After couple of minutes, you can see HANA Cloud Instance Running

Creating a HANA Database Application from SAP Business Application Studio

Refer https://eightbits.medium.com/sap-business-technology-platform-cloud-foundry-runtime-overview-131abeb33b23 for setting up BAS.

Once the editor is launched, you need to adjust your current workspace to CF account. You can do this by clicking on Terminal Menu > New Terminal

use cf login, enter the credentials and select the sub account and space from interactive menu.

Press enter or click to view image in full size

Next click on “Start from template” Create new Project > Select HANA Project

Provide the project name in our case its foodie. Next enter the module name or you can use the default value db.

Next provide the database information like namespace, schema name and DB version (In our case it HANA Cloud)

Next bind the application to HDI container service, more details on using HDI can be found here https://saphanajourney.com/data-warehouse-cloud/learning-article/sap-hana-cloud-deployment-infrastructure-hdi-container/

As we have not created any HDI instance yet, you can choose to create new by providing a unique name or use the value provided by default. Next click on Finish

It will take a minute and workspace will be refreshed with newly created project.

Get Suraj Acharya’s stories in your inbox

Join Medium for free to get updates from this writer.

You can verify schema from SAP HANA Database Explorer

Next let us create a simplet hdbtable like below

If you observe the schema name provided by us is FOODIE, but its created as FOODIE_1. You can find more details on this here

https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.03/en-US/221aeeced301403d8913fc1a4ee31434.html

You can deploy your changes to container, by clicking on deploy icon in SAP HANA Projects in left menu.

Now you can verify that table name PREFERENCE is visible.

Okay, now we deployed to container, but how to make the artifacts deliverable?

Creating MTA

Refer https://sap.github.io/cloud-mta-build-tool/usage/ for mta build tool usage. When you directly make -f Makefile.mta p=cf in the terminal, you get error No such file or directory like below

user: foodie $ make -f Makefile.mta p=cf

make: Makefile.mta: No such file or directory

make: *** No rule to make target ‘Makefile.mta’. Stop.

You need to execute mbt init command to generate Makefile.mta in current project.

$ mbt init

$ make -f Makefile.mta p=cf

Now under mta_archives you can see the mtar generated.

Deploying the MTAR application to Cloud Foundry

https://cap.cloud.sap/docs/advanced/deploy-to-cloud

$ cf deploy ./mta_archives/foodie_0.0.1.mtar

You should see below logs, which creates a new HDI-service, binds the DB, deploys the MTA modules.

You can also verify the same from Instances and Subscriptions in SAP BTP Cockpit.

Operation ID: 77aaedd8-cc51–11eb-840d-eeee0a8d1aef
Operation ID: 77aaedd8-cc51–11eb-840d-eeee0a8d1aef
Deploying in org “52121c4ctrial” and space “dev”
Detected MTA schema version: “3”
No deployed MTA detected — this is initial deployment
Detected new MTA version: “0.0.1”
Processing service “hdi_db”…
Creating service “hdi_db” from MTA resource “hdi_db”…
0 of 1 done, (1 creating)
0 of 1 done, (1 creating)
0 of 1 done, (1 creating)
0 of 1 done, (1 creating)
0 of 1 done, (1 creating)
0 of 1 done, (1 creating)
1 of 1 done
Updating application “db”…
Application “db” attributes are not modified and will not be updated
Binding service instance “hdi_db” to application “db”…
Uploading application “db”…
Started async upload of application “db”
Staging application “db”…
Application “db” staged
Executing task “deploy” on application “db”…
Skipping deletion of services, because the command line option “ — delete-services” is not specified.
Process finished.
Use “cf dmol -i 77aaedd8-cc51–11eb-840d-eeee0a8d1aef” to download the logs of the process.
user: foodie $ cf deploy ./mta_archives/foodie_0.0.1.mtar
Deploying multi-target app archive ./mta_archives/foodie_0.0.1.mtar in org 52121c4ctrial / space dev as swarnagouri.bhat@gmail.com…

Uploading 1 files…
/home/user/projects/foodie/mta_archives/foodie_0.0.1.mtar
OK
Operation ID: f7990fdc-cc52–11eb-86a2-eeee0a93562c
Operation ID: f7990fdc-cc52–11eb-86a2-eeee0a93562c
Deploying in org “52121c4ctrial” and space “dev”
Detected MTA schema version: “3”
Detected deployed MTA with namespace “null”, ID “foodie” and version “0.0.1”
Detected new MTA version: “0.0.1”
Deployed MTA version: “0.0.1”
Processing service “hdi_db”…
Creating service “hdi_db” from MTA resource “hdi_db”…
0 of 1 done, (1 creating)
0 of 1 done, (1 creating)
0 of 1 done, (1 creating)
0 of 1 done, (1 creating)
0 of 1 done, (1 creating)
1 of 1 done
Updating application “db”…
Application “db” attributes are not modified and will not be updated
Binding service instance “hdi_db” to application “db”…
Uploading application “db”…
Content of application “db” is not changed — upload will be skipped.
Executing task “deploy” on application “db”…
Skipping deletion of services, because the command line option “ — delete-services” is not specified.
Process finished.

--

--

Suraj Acharya
Suraj Acharya

Written by Suraj Acharya

Senior Developer - SAP Labs India