Skip to Content
Technical Articles

hana-cli: XSA MTA project in VS Code

Last time I wanted to play with hana-cli. I walked through the guide provided by (@Thomas Jung) and wanted to check out, what I can achieve with that.

If You are not familiar with hana-cli, please check first post blog/videos prepared by Thomas:

I came up with a simple task for my self to setup an existing XSA project for development in Visual Studio Code.

It took me a few hours, I learned a lot, and I prepared this blog post. I hope it will help someone.

Why I would like to develop XSA MTA application in VS Code anyway? There could be a few reasons:

  • GIT console
  • Faster IDE
  • Node modules

But I treat it as a pure fun experiment and learning lesson.

Environment preparation

1. Install Node.js version 10.x or 12.x
2. Clone Your XSA project into a folder using git clone command
3. Add the SAP Registry to your NPM configuration

npm config set @sap:registry=

4. Install hana-cli as a global module

npm install -g hana-cli

Connection setup

Now, to set up the connection between hana container and local project (hana-cli) we need to create a default-env.json file in db folder. It is a JSON file which contains a set of environment variables and their values. There we need to provide variables describing HDI container params which were generated for our XSA project.

`default-env.json` example file with a target container binding and a user-provided service:

  "TARGET_CONTAINER" : "target-service",
    "hana" : [ {
     "name" : "target-service",
      "label" : "hana",
      "tags" : [ "hana", "database", "relational" ],
      "plan" : "hdi-shared",
      "credentials" : {
        "schema" : "SCHEMA",
        "hdi_user" : "USER_DT",
        "hdi_password" : "PASSWORD_DT",
        "certificate" : "-----BEGIN CERTIFICATE-----\nABCD...1234\n-----END CERTIFICATE-----\n",
        "host" : "host",
        "port" : "30015"
    } ],
    "user-provided" : [ {
      "name" : "GRANTING_SERVICE",
      "label" : "user-provided",
      "tags" : [ ],
      "credentials" : {
        "schema" : "SYS",
        "user" : "GRANT_USER",
        "password" : "PASSWORD",
        "procedure_schema" : "PRIVILEGE_PROCEDURE_GRANTOR_DEFINER",
        "procedure" : "GRANT",
        "type" : "procedure",
        "tags" : [ "hana" ]
    } ]

Where we can find those properties for our project? – XSA Cockpit

Open SAP HANA XS Advanced Cockpit and navigate through:
Organization -> Space -> Your application, and select Environment Variables from the left menu.

In System-Provided section You should see configuration similar to the template above. You can copy sensitive data, but JSON has to be adjusted according to the above template.

To check if the configuration is correct type in terminal:

hana-cli status

If everything is fine, run:

npm start
//"start": "node node_modules/@sap/hdi-deploy/deploy.js --exit --auto-undeploy"

To build a project in a defined container. It is the same step which is done in Web IDE for building db folder.


If You did everything well – You can continue working on Your project in VS Code now 🙂 I found a lot of useful pieces of information in README of @sap/hdi-deploy node module. TThere are also a lot of explanations, how this module works and how to configure it correctly. I recommend to read that, to better understand the topic.

Bonus: Cloud MTA Build Tool

As a bonus to this task, I did test run for Cloud MTA Build Tool. Using MBT we could build the whole project to mtar file.

1. Install MBT as global module

npm install -g mbt

2. Build project with XSA flag

mbt build -p=XSA

And that’s it!

*.mtar file should be created in Your project directory.

You must be Logged on to comment or reply to a post.
  • Very happy to see that you found the hana-cli sample interesting and especially glad to see that you shared your learnings via a blog entry of your own. Nice job!

  • Thank you for sharing!

    I came across the following error: Error: Connection failed (RTE:[300006] Cannot create certificate store

    I was able to solve this by removing the certificate in the credentials and add these parameters instead:

    Do you know a better way to solve this problem?