Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
michal_majer
Active Participant
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: https://blogs.sap.com/2020/03/26/hana-cli-sample-how-to-build-a-node.js-command-line-interface/

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=https://npm.sap.com

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.

Template:
`default-env.json` example file with a target container binding and a user-provided service:
{
"TARGET_CONTAINER" : "target-service",
"VCAP_SERVICES" : {
"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.
12 Comments
thomas_jung
Developer Advocate
Developer Advocate
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!
WouterLemaire
Active Contributor

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:

                    “validate_certificate”:false,
                    “encrypt”:true
Do you know a better way to solve this problem?
Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
Hi hii757

I believe this issue can be corrected by checking if you can run sapgenpse at any path. Open a command prompt and run this command. It should show you some information, including the environment variable SECUDIR location. If it doesn't recognize it as a valid command, then check your path environment variable. I had to enter mine without using the SECUDIR variable so it would work - didn't stop to try to understand why.

Best regards,
Ivan
drvup
Contributor
0 Kudos
I had something similiar. The reason was simple: The database wasn't available from outside the SCP. Check the settings of the database, if it's available from 'everywhere'.
faebulicious
Explorer
ivan.mirisola worked like a charm. Many thanks!
former_member655698
Discoverer
0 Kudos
Hi Thomas. Thanks for your contributions..

My research for ways to improve my SDLC around the SAP HANA & XSA environments brought me here.  Would you have some point form tips to share? For example:

  • Online course material

  • Community groups, blogs, etc.

  • Relative publications from SAP that I can subscribe to stay informed; and perhaps SAP's roadmap to provide VSCode extension that allows a distributed & localized experience

former_member655698
Discoverer
0 Kudos
Thank you Majer.

In reference to the XSA Cockpit, are there some specific switches/params/args we could provide the XS CLI to get the configurations we need?  I don't have familiarity with the cockpit, nor do I have the access without the assist from administrators, which makes getting this setup a difficult task.
michal_majer
Active Participant
0 Kudos
adamwest2924 XS-CLI should have similar possibilities as cloud foundry CLI. The most important part for this configuration are environment variables (default-env.json file).

It is possible to get it using cf CLI, so maybe the same will work for XS:
xs env name-of-the-application

xs help
thomas_jung
Developer Advocate
Developer Advocate
0 Kudos
Not sure I'm exactly sure what you are looking for here.  Groups/blogs/etc - you are in the right place. I'd suggest following the HANA tag here in the community.  We also have HANA content such as tutorials in the developer center. SAP Tutorial Navigator | Tutorials for SAP Developers  We have just been adding some new tutorials that cover HANA Cloud development with CAP in the Business Application Studio. We also have videos in the SAP Developers channel on YouTube. SAP HANA - YouTube.  Maybe that helps
Ahmedkhan29789
Participant
0 Kudos

Hi Michal,

Wonderful blog, Thanks for your efforts,

I was also trying it the same you stated in this blog, but not able to understand in which db folder I have to create the default-env.json file. I am using HANA XSA WebIDE  for development.

this is what i have done,

Installed node js in my local computer

set

npm config set @sap:registry=https://npm.sap.com

Installed hana-cli

npm install -g hana-cli

next i open my command prompt and try to open hana-cli UI interface

for example: hana-cli massconvertui

and i am getting this when ui is opening for mass convert.

"Error: Missing configuration file. No default-env.json or substitute found. Full Details: VError: No service matches hana"

Kindly suggest me some solution.

 

michal_majer
Active Participant
0 Kudos
Hey khanaliahmed2989

Well, it all depends on how Your project is structured. You have to create the default-env.json file on Your own in the main folder module related to HANA DB development. In my example above, my module had 'db' name, in Your case the folder name is probably different.

Best,
Michal

 

 

 
Arif1
Active Participant
0 Kudos
hana-cli status
Error: Missing configuration file. No default-env.json or substitute found. Full Details: VError: No service matches hana

But my XS service is running

Can you please share some more details
Labels in this area