Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an SAP Cloud Application Programming Model Project for SAP HANA Cloud #663

Closed
LotharBender opened this issue Oct 15, 2021 · 1 comment
Assignees

Comments

@LotharBender
Copy link

LotharBender commented Oct 15, 2021

Tutorials: https://developers.sap.com/tutorials/hana-cloud-cap-create-project.html

Write here how you think we can improve the tutorial ...
The tutorial steps 5.1 - 5.8 and 6.5 describe a workaround in order to enable a CAP project for the SAP HANA Tools. By default CAP Nodejs projects are using a deployment staging folder /gen/db/** which causes issues when working with SAP HANA Tools as these tools are assuming that all HANA artefacts are contained in a folder /db/src/**.
Unfortunately the workaround described in the tutorial does not cover all steps required for the migration of the service module srv. As a consequence deploying the srv module to Cloud Foundry will fail. Additional steps are required to successfully deploy and run the CAP services defined in the srv module. A package.json file is required and an entry "model": "gen/csn.json" has to be added to the requires.db configuration in the package.json file.

I've found a different workaround that is much simpler, only affects the db module and leaves the srv module as is avoiding the inconsistencies described above. The workaround makes use of the CAP build task feature instead - https://github.wdf.sap.corp/pages/cap/advanced/deploy-to-cloud
You may want to give it a try and decide...

  1. Create a CAP project with having Basic Sample Files selected. This is important in order to successfully execute the cds build --for hana command described in the next step.
  2. Execute CDS HANA build once in order to generate a package.json which you have to copy into the db folder of your project (avoiding step 6.5 magic):
    cds build --for hana
    copy the file gen/db/package.json into the db folder
  3. Replace the existing cds config section of the package.json file located in the root folder of your project. For further details regarding the configuration of different databases used for local development or production test scenarios see https://cap.cloud.sap/docs/node.js/cds-env#profiles
"cds": {
    "build": {
       "tasks": [
           { "for":"hana",  "dest": "../db" },
           { "for":"node-cf" }
       ]
    },
    "hana": {
        "deploy-format": "hdbtable"
    },
    "requires": {
        "db": {
            "kind": "hana"
        }
    }
}
  1. Execute the following command in order to update the path entry of the db module mta.yaml or change the path yourself as described below:
    cds add mta --force
# -------------------- SERVER MODULE ----------------------
 - name: MyHanaApp-srv
 # ------------------------------------------------------------
   type: nodejs
   path: gen/srv  
. . .

 # -------------------- SIDECAR MODULE --------------------
 - name: MyHanaApp-db-deployer
 # ------------------------------------------------------------
   type: hdb
   path: db  #gen/db
. . .

Done!
By the way the temporary problem mentioned in 3.1 does no longer exist. Thus user can use the wizard...

@jung-thomas
Copy link

Thank you for the suggestion. We will consider it for future updates to this tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants