SAP HANA Local Native Development

Aus MattWiki
Version vom 5. März 2021, 13:45 Uhr von Matt (Diskussion | Beiträge) (Matt verschob die Seite SAP HANA Local Native Development nach SAP HANA Local CDS and Native Development, ohne dabei eine Weiterleitung anzulegen)

This article describes how to develop HANA native database modules locally without Web IDE and even without XSA server.

The approach described below deploys the data to a local SAP HANA Express but it could be deployed to Cloud Foundry as well.

hana-cli is a tool from SAP development which contains some scripts which reproduce the behavior of the Web IDE when building and deploying apps. Without the Web IDE one could use CF / XS to create the appropriate services, which are built tand deployed by the Web IDE. But if one wants to work even without CF / XSA server all of the tasks need to be done with the appropriate NPM tools. In order to make this easier hana-cli comes into play.

Source: ABAP Freak Show Ep. 6 - HANA; Local Development, VCAP_SERVICES, and HDI Deployer Tips and Tricks -> https://www.youtube.com/watch?v=JLfv04rlmfI

Installation of Tools

Relevant Tools from SAP

npm i -g @sap/cds
npm i -g @sap/cds-dk

Additional 3rd Party Tools1

npm i -g hana-cli

Setup Project

Create a new folder for the project.

Create a DB module inside the project:

hana-cli createModule

Connect to HANA DB - if asked for user don't forget to enter a HANA user, not a XSA user:

hana-cli connect

Get different infos of connected server:

hana-cli systemInfo -a
hana-cli status -a
hana-cli schemas -a

Create HDI Container

hana-cli createContainer

This actually uses SQL statements to create the HDI container to execute the same processes as the build function in the Web IDE would do. When asked for a container name remember to use a unique name. The Web IDE by default adds a _1 at the end of the name of the HDB module.

The createContainer statement needs to be issued from the db folder of the project. Also a default-env-admin.json file is needed in the db folder as well. This creates a default-env.json file which contains the connection details. Now the following statement without the -a is available (which stands for admin):

hana-cli status

This shows the current user, which should be the runtime user and also its roles in the HANA db.

Build and Deploy Project

First let NPM download the necessary libraries that the project depends on. i.e. @sap/hdi-deploy, which are defined in package.json

npm install -global

Now start the deploy process defined in the package.json by issuing:

npm start

Check crated tables:

hana-cli tables