Skip to Content
Technical Articles
Author's profile photo Jhodel Cailan

Testing MTA-based app runtime in VS Code

If you have been working on HANA XSA development or SCP Cloud Foundry, chances are that you have been working exclusively using SAP WebIDE Full-stack, and this was the case for me, until I have noticed the popularity of VS Code and one day I decided to give it try and over the course of time it became clear to me what I’ve been missing all this while. The bottom line is that it helped to speed up my development time and be able to do advance debugging and troubleshooting.  The only downside is that, there are some configuration steps you need to do to get started. This blog can help to get you started on testing your MTA-based app runtime, in which I will use nodejs runtime, using VS Code as a local development IDE while connected to SAP HANA DB in SAP Cloud Platform.


  • Visual Studio Code Development IDE
  • SAP Cloud Platform Account
  • You already know how to build and deploy an MTA-based Application to SCP Cloud Foundry


Setup connection to HDI Container

This section describes the steps to connect your nodejs application to your already deployed HDI Container (SAP HANA DB) in SCP Cloud Foundry. It is already assumed here that you have deployed the HANA DB Artifacts into an HDI Container and we are now going to connect to that HDI container.

Let’s checkout first my sample project, which is the solution project for the hands-on exercise on openSAP course Software Development on SAP HANA 2019.  You can browse the sample project in this GitHub Repo

Now, using the solution that is known to work using SAP WebIDE, let’s start to run the nodejs module in the folder called “XSJS”.

Right Click on XSJS folder > Open in Terminal > Execute command: npm run start

Notice that in the screenshot above, there were logs stating that no service found for HANA and therefore the OData services will be disabled.  This problem is expected on a local development environment. And this is the part where we are going to start to setup the connection by following a few simple steps.

  • 1. Go to your SCP Cockpit in Cloud Foundry and look for HDI Container service you want to connect to. Copy the “sensitive data” information (JSON data) because this contains the credentials that your nodejs application need to connect to this HCI Container.

  • 2. Switch back to VS Code and create a file called “default-services.json” inside the XSJS folder.  The content of the file should have a root property called “hana” and its value is the entire JSON data you copied from the SCP Cockpit.  The resulting content should look like the one in the screenshot below:

Important Note!! 

You shouldn’t include default-services.json file in your commits to your project repository because this is used to contain the credentials of your HDI Container in SCP Cloud Foundry. And you shouldn’t commit any sensitive data into your code repository.

Make sure that you add an entry in the file “.gitignore” like the one below:

Luckily, the MTA Project template I generated from SAP WebIDE already included entry in .gitignore file for default-*.json.  VS Code will display the files/folders in grey if they are ignore by git.

  • 3. At this point, we are ready to run our nodejs application to check if we can connect to the HANA HDI Container.

Once again, run the command > npm run start

Notice that the problematic logs about not being able to connect to HANA service are now gone and take a look at the 2nd to last line of logs, it mentioned that the service is using an encrypted HANA connection. This means that the nodejs module is now connected to the HANA HDI Container! Woohoo!

  • 4. The last thing to do is to test the application if it can really provide data from the HDI container.  We can do this by doing query from an existing XSODATA service included in the sample project.

As you can see, the data is returned by the OData service, and this is the exact data coming from the HDI container.



Now we can say that it’s quite easy to setup a connection to an HDI container from our nodejs module.  We didn’t even need to change anything in our existing code.  The trick here is to make sure that you have conform to the service key (which is “hana”) in the default-services.json file and provide the necessary credentials as its value. The rest is taken cared of by the @sap/xsenv node module.

Now you know how to use VS Code and be able to connect to your HDI container. The next step is to dig into an advanced debugging and troubleshooting using VS Code debugger, and I will talk about this in my next blog. Stay tuned!

Update: here’s the continuation — Advanced debugging of MTA-based Apps

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Stephen Le
      Stephen Le

      Hi Jhodel Cailan,

      Thanks a lot for such a great series. I would like to ask if you can help to address this below issue that I had during my local db build and local running of my service module using visual studio code. Here's the error detail that might be the root cause for all:

      Error: Connection failed (RTE:[300006] Cannot create certificate store (

      Earlier, I have not provided the default-services.json and I got the same issue like you had: "no services matches hana". Then I added the file in and this issue was gone, I was able to run my service and also was able to run a health-check of my service. But when I connect to my odata endpoint, I always got this error and I believe that this certificate is the causing the db not able to be built as well as the service not able to run properly. I really do appreciate if you can help me out with this.



      Author's profile photo Jhodel Cailan
      Jhodel Cailan
      Blog Post Author

      Thanks Stephen Le !

      I'm quite sure that I encountered this kind of error before, just not sure if it's in the same context of this blog post.

      Maybe you can try this alternative approach:

      • Go to your deployed OData service in SCP > environment variables > and get the credentials from there instead

      Then use that to connect to your HANA DB from your local IDE.

      Author's profile photo Sebastian Mantsch
      Sebastian Mantsch

      Hi Stephen Le,

      the issue you are experiencing should be caused by the missing "SAP CommonCryptoLib" as it's mentioned in following troubleshooting guide: CAP HANA Troubleshooting

      Make sure you install the corresponding version of the Crypto Library for your OS and after that the CAP runtime should be able to connect to the HANA DB Service through the method provided above.



      Author's profile photo Adam Cox
      Adam Cox

      Great post!  What is your local environment?  It looks like Mac/linux?  What if I have a Windows box?  Do I need to set up WSL?  Where to start with SAP MTA app dev with regards to learning and documentation?  While I find documentation it seems sparse in the area of examples.  For example, I recently want to implement logging in an MTA.  While I find some docs about it, I have no idea where or how to access the logs themselves from the WebIDE.  The WebIDE does have links to open logs in browser but I do not see any logs entries that I have composed from the code so unsure if I am looking at the correct logs (because they don’t make reference to how to view from WebIDE user perspective.  Meh!  Thanks again!

      Author's profile photo Jhodel Cailan
      Jhodel Cailan
      Blog Post Author

      Hi Adam Cox

      Thanks for your comment! I'm using Mac but I did try building MTA-based apps using Windows machine as well, and I don't use WSL -- so that's actually optional. The SAP WebIDE is already discontinued, and I don't suggest for you to continue with that. I suggest you look into SAP Business Application Studio or Visual Studio Code.

      Also, when learning MTA, a good place to start now is by starting with SAP Cloud Application Programming Model aka CAP.

      I've written a number of blog posts about CAP, and there's also an openSAP course about it.

      Hope it helps! Cheers!

      Author's profile photo Adam Cox
      Adam Cox

      Thanks!  Where is the best place to get help with MTA work?  I try and figure a way to get the version from mta.yaml at during nodejs runtime. Any idea? Thanks again..