SAP Cloud Application Programming Model Getting Started (CAP): Unterschied zwischen den Versionen

Aus MattWiki
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 54: Zeile 54:
  cds compile srv/cat-service.cds --to hana    # Creates hdbcds or hdbtable/hdbview artefacts
  cds compile srv/cat-service.cds --to hana    # Creates hdbcds or hdbtable/hdbview artefacts
   
   
== Deployment to SAP Business Technology Platform (BTP) ==


=== With Cloud Foundry CLI ===
cds add hana
''package.json'' needs to contain ''"kind": "hana"''. Also when deploying to BTP which is internally HANA 4.0 ''"deploy-format": "hdbtable"'' has to be set. Example:
<syntaxhighlight lang="JSON">
{
    ...
    "cds": {
        "hana": {
            "deploy-format": "hdbtable"
        },
        "requires": {
            "db": {
                "model": [
                    "db",
                    "srv"
                ],
                "kind": "hana"
            }
        }
    }
}
</syntaxhighlight>
After that build the deployment artifacts and create a hana service for the hdi-container. The stated hdi-container name must correlate to the services-name in ''/gen/db/src/manifest.yaml''.
cds build/all
cf create-service hana hdi-shared <app-db-hdi-container>
Now push the DB deployer application and also the actual service application:
cf push -f gen/db
cf push -f gen/srv --random-route
=== Troubleshooting ===
Real-time output of CF services can be displayed in BAS terminal with
cf logs <appname>


[[Category:SAP]]
[[Category:SAP]]
[[Category:HANA]]
[[Category:HANA]]

Version vom 13. Mai 2021, 19:26 Uhr

This article describes how to build Cloud Application Programming Model projects (CAP projects) and according artefacts with Core Data Services (CDS).

Source: ABAP Freak Show Ep. 1 - HANA Cloud and the Business Application Studio

https://www.youtube.com/watch?v=a3WPQwmpbvI&list=PLoc6uc3ML1JR38-V46qhmGIKG07nXwO6X&index=71

For local native development see SAP HANA Local Native Development

All-in-one Quick Start: https://github.com/SAP-samples/cloud-cap-walkthroughs/blob/master/exercises-node/intro/README.md

More Repositories: https://github.com/SAP-samples/cloud-cap-samples --> Use opensap*-Branches

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 CDS Project

cds init bookshop

or

cds init MyCDSProject --add hana, mta

Start Service

cds watch

This also monitors changes to the underlying files and restarts when a file has changed.

Create Persistency from CDS

cds deploy --to sqlite          # Deploys to sqlite.db
cds deploy --to sqlite:my.db    # Deploys to my.db
cds deploy --to hana            # Deploys to HDI container on HANA
                                # (Requires Cloud Foundry login)    

This also updates the package.json

Deployment to sqlite requires node module sqlite3. To install it execute in the root of the project folder:

npm install sqlite3

In order to see the actual created SQL statements:

cds compile srv/cat-service.cds --to sql     # Creates SQL statements
cds compile srv/cat-service.cds --to hana    # Creates hdbcds or hdbtable/hdbview artefacts

Deployment to SAP Business Technology Platform (BTP)

With Cloud Foundry CLI

cds add hana

package.json needs to contain "kind": "hana". Also when deploying to BTP which is internally HANA 4.0 "deploy-format": "hdbtable" has to be set. Example:

{
    ...
    "cds": {
        "hana": {
            "deploy-format": "hdbtable"
        },
        "requires": {
            "db": {
                "model": [
                    "db",
                    "srv"
                ],
                "kind": "hana"
            }
        }
    }
}

After that build the deployment artifacts and create a hana service for the hdi-container. The stated hdi-container name must correlate to the services-name in /gen/db/src/manifest.yaml.

cds build/all
cf create-service hana hdi-shared <app-db-hdi-container>

Now push the DB deployer application and also the actual service application:

cf push -f gen/db
cf push -f gen/srv --random-route


Troubleshooting

Real-time output of CF services can be displayed in BAS terminal with

cf logs <appname>