SAP HANA Local Native Development: Unterschied zwischen den Versionen
Matt (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Matt (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
(12 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
This article describes how to develop HANA native database modules locally without Web IDE and even without XSA server. | This article describes how to develop HANA native database modules locally without Web IDE and even without XSA server. | ||
For CAP development with CLI see [[SAP Cloud Application Programming Model Getting Started (CAP)]] | |||
The approach described below deploys the data to a local SAP HANA Express but it could be deployed to Cloud Foundry as well. | The approach described below deploys the data to a local SAP HANA Express but it could be deployed to Cloud Foundry as well. | ||
Source: HANA; Local Development, VCAP_SERVICES, and HDI Deployer Tips and Tricks | |||
https://www.youtube.com/watch?v=NtuxQam_9BY | |||
== Introduction == | |||
''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. | ''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. | ||
== How does Deployment work in Web IDE? == | |||
The deployment of HDI containers is done by a node.js based deployment script ''deploy.js'' stated in the ''/db/package.json'': | |||
<syntaxhighlight lang="JSON"> | |||
{ | |||
"name": "deploy", | |||
"dependencies": { | |||
"@sap/hdi-deploy": "^3.8.2" | |||
}, | |||
"engines": { | |||
"node": "^8" | |||
}, | |||
"scripts": { | |||
"postinstall": "node .build.js", | |||
"start": "node node_modules/@sap/hdi-deploy/deploy.js" | |||
} | |||
} | |||
</syntaxhighlight> | |||
== Installation of | == Installation of Prerequisites == | ||
'''Relevant Tools from SAP''' | '''Relevant Tools from SAP''' | ||
Zeile 22: | Zeile 44: | ||
npm i -g hana-cli | npm i -g hana-cli | ||
== | == Create a New Project from Scratch == | ||
=== Setup Project === | === Setup Project === | ||
Zeile 34: | Zeile 56: | ||
Connect to HANA DB - if asked for user don't forget to enter a HANA user, not a XSA user: | Connect to HANA DB - if asked for user don't forget to enter a HANA user, not a XSA user: | ||
hana-cli connect | hana-cli connect (Execute in DB folder) | ||
Get different infos of connected server: | Get different infos of connected server: | ||
Zeile 68: | Zeile 90: | ||
hana-cli tables | hana-cli tables | ||
== | == Add Configurations to Existing Project == | ||
=== Establish Connection === | |||
hana-cli connect (Execute in DB folder) | |||
This creates a ''default-env-admin.json'' file which kind of simulates a XSA / CF backend. | |||
== Create Local Runtime Environment with default-env.json == | |||
The ''default-env.json'' enables you to run CF environments on your development machine or in the SAP BTP without deploying applications to the CF. | |||
<syntaxhighlight lang="json"> | |||
cds{ | |||
"SERVICE_REPLACEMENTS": [ | |||
{ | |||
"key": "ServiceName_1", | |||
"service": "CROSS_SCHEMA_SFLIGHT" | |||
}, | |||
{ | |||
"key": "hdi-user-service", | |||
"service": "hana-opensap-cloud-2020-user-db" | |||
} | |||
], | |||
"VCAP_SERVICES": { | |||
"xsuaa": [ | |||
{ | |||
"name": "bookshop-uaa", | |||
"label": "xsuaa", | |||
"tags": [ | |||
"xsuaa" | |||
], | |||
"credentials": { | |||
... | |||
} | |||
} | |||
], | |||
"hana": [ | |||
{ | |||
"name": "hana-opensap-cloud-2020-db", | |||
"tags": [ | |||
"hana" | |||
], | |||
"credentials": { | |||
... | |||
} | |||
} | |||
] | |||
} | |||
} | |||
</syntaxhighlight> | |||
'''Add Database Connection to default-env.json''' | |||
hana-cli serviceKey hana-opensap-cloud-2020-db default | |||
hana-cli status | |||
hana-cli systemInfo | |||
'''Add Authentication to default-env.json''' | |||
See https://cap.cloud.sap/docs/node.js/authentication | |||
'''Add Service Replacements to default-env.json''' | |||
Add Section SERVICE_REPLACEMENTS (see above) | |||
Aktuelle Version vom 11. Februar 2024, 10:49 Uhr
This article describes how to develop HANA native database modules locally without Web IDE and even without XSA server.
For CAP development with CLI see SAP Cloud Application Programming Model Getting Started (CAP)
The approach described below deploys the data to a local SAP HANA Express but it could be deployed to Cloud Foundry as well.
Source: HANA; Local Development, VCAP_SERVICES, and HDI Deployer Tips and Tricks
https://www.youtube.com/watch?v=NtuxQam_9BY
Introduction
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.
How does Deployment work in Web IDE?
The deployment of HDI containers is done by a node.js based deployment script deploy.js stated in the /db/package.json:
{
"name": "deploy",
"dependencies": {
"@sap/hdi-deploy": "^3.8.2"
},
"engines": {
"node": "^8"
},
"scripts": {
"postinstall": "node .build.js",
"start": "node node_modules/@sap/hdi-deploy/deploy.js"
}
}
Installation of Prerequisites
Relevant Tools from SAP
npm i -g @sap/cds npm i -g @sap/cds-dk
Additional 3rd Party Tools1
npm i -g hana-cli
Create a New Project from Scratch
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 (Execute in DB folder)
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
Add Configurations to Existing Project
Establish Connection
hana-cli connect (Execute in DB folder)
This creates a default-env-admin.json file which kind of simulates a XSA / CF backend.
Create Local Runtime Environment with default-env.json
The default-env.json enables you to run CF environments on your development machine or in the SAP BTP without deploying applications to the CF.
cds{
"SERVICE_REPLACEMENTS": [
{
"key": "ServiceName_1",
"service": "CROSS_SCHEMA_SFLIGHT"
},
{
"key": "hdi-user-service",
"service": "hana-opensap-cloud-2020-user-db"
}
],
"VCAP_SERVICES": {
"xsuaa": [
{
"name": "bookshop-uaa",
"label": "xsuaa",
"tags": [
"xsuaa"
],
"credentials": {
...
}
}
],
"hana": [
{
"name": "hana-opensap-cloud-2020-db",
"tags": [
"hana"
],
"credentials": {
...
}
}
]
}
}
Add Database Connection to default-env.json
hana-cli serviceKey hana-opensap-cloud-2020-db default hana-cli status hana-cli systemInfo
Add Authentication to default-env.json
See https://cap.cloud.sap/docs/node.js/authentication
Add Service Replacements to default-env.json
Add Section SERVICE_REPLACEMENTS (see above)