In this exercise you will use the SAP CAP project wizard in SAP Business Application Studio to scaffold a new CAP Node.js application that is pre-configured to target SAP HANA Cloud as its database. By the end you will have a working project skeleton, a Git repository to track your changes, and a Cloud Foundry login ready for HDI container deployment.
SAP Cloud Application Programming Model (CAP) is SAP's opinionated framework for building full-stack cloud-native applications. Rather than writing raw SQL or low-level service code, you describe your data model and services in CDS (Core Data Services) — a high-level, declarative language — and CAP generates the boilerplate for you: OData endpoints, database tables, service bindings, and more.
By default, CAP uses an in-memory SQLite database for local development. To use SAP HANA Cloud instead, you need to configure the project for HDI (HANA Deployment Infrastructure) — the mechanism that deploys and manages database artifacts inside an isolated HANA container. The CAP wizard handles this configuration for you automatically.
The CAP project wizard in SAP Business Application Studio generates the project skeleton, sets up the package.json with the correct SAP dependencies, and adds the mta.yaml deployment descriptor needed for Cloud Foundry deployment.
👉 Perform all the steps in the tutorial: Create an SAP Cloud Application Programming Model Project for SAP HANA Cloud
What the wizard creates: After running the wizard, your project contains a
db/folder for your data model, asrv/folder for your service definitions, anapp/folder for any UI content, and apackage.jsonthat already includes@sap/cds,@sap/hdi-deploy, and other SAP-specific dependencies.
Before you can deploy or bind an HDI container, the Cloud Foundry CLI in BAS needs to know which Cloud Foundry organization and space to use.
👉 In BAS, open the command palette and run CF: Login to Cloud Foundry. Select your API endpoint, provide your credentials, and select the org and space where your HANA Cloud instance is mapped.
Why Cloud Foundry? SAP HANA Cloud instances are provisioned in a "multi-environment" context — the database itself is not running inside Cloud Foundry — but HDI containers are still created and managed as Cloud Foundry service instances (using the
hanaservice with thehdi-sharedplan). Logging in lets the CAP tooling find and bind those containers later.
Version control is important from day one. The tutorial has you initialize a local Git repository so you can track every change you make as you progress through the exercises.
👉 Follow the Git initialization steps in the tutorial. Stage and commit your initial project files once the wizard finishes.
Local vs. remote: A local Git repository gives you commit history and the ability to revert changes, but the code only lives on your BAS dev space. In a real project you would push to a central repository (GitHub, GitLab, Azure DevOps, etc.) for backup, collaboration, and CI/CD integration.
At the end of this exercise you have:
- A CAP Node.js project scaffolded and configured for SAP HANA Cloud
- A
package.jsonwith the correct SAP dependencies (@sap/cds,@sap/hdi-deploy, etc.) - An
mta.yamldeployment descriptor ready for Cloud Foundry MTA builds - A Cloud Foundry CLI session pointed at the correct org and space
- A local Git repository with an initial commit
-
What is the value of the dev space in SAP Business Application Studio? To help with this discussion point consider the prerequisites section for not using SAP Business Application Studio.
Answer
A dev space is a pre-configured, containerized development environment in BAS tailored to a specific scenario — such as Full Stack Cloud Application, SAP Fiori, or SAP HANA Native. It ships with the correct extensions, CLI tools (`@sap/cds-dk`, Cloud Foundry CLI, MTA Build Tool), and runtimes already installed, so you can start coding immediately without any local setup.The trade-off versus a local environment like VS Code is that BAS requires an internet connection and runs inside SAP BTP, which can simplify connectivity to SAP services. SAP also provides a CDS language extension for VS Code for developers who prefer to work locally — see the prerequisites for details.
-
Why was it necessary to log in to Cloud Foundry, even though SAP HANA Cloud itself is not running inside Cloud Foundry?
Answer
SAP HANA Cloud is provisioned in a multi-environment context — the database is not tied to Cloud Foundry — but **HDI containers** (the isolated schemas where your database artifacts live) are still created and managed as Cloud Foundry service instances using the `hana` service with the `hdi-shared` plan.When you run
cds deployor build the MTA, the CAP tooling uses your Cloud Foundry session to discover, create, or bind to the correct HDI container in the target space. Without a CF login, the tooling cannot locate or provision the container. See HDI containers for more detail. -
What is the purpose of the
mta.yamlfile?Answer
`mta.yaml` is the deployment descriptor for a **Multi-Target Application (MTA)** — a bundle that groups multiple deployable components (a database module, a CAP service module, a UI app, an AppRouter, etc.) into a single archive that can be deployed atomically to Cloud Foundry.In this project the
mta.yamldefines:- A db module (
MyHANAApp-db) that runs@sap/hdi-deployto push database artifacts into the HDI container - A srv module (
MyHANAApp-srv) that runs the CAP Node.js service and exposes thesrv-apidestination - Resources for the HANA HDI container and (later) XSUAA, which Cloud Foundry provisions as service instances
See the MTA specification for the full descriptor reference.
- A db module (
-
Who can explain what NPM is and how it is used in this project?
Answer
NPM (Node Package Manager) is the standard package manager for Node.js. It reads `package.json` to install the libraries your project depends on and makes them available in `node_modules/`.Key packages in this CAP project:
@sap/cds— the CAP runtime: processes CDS models, serves OData endpoints, handles database queries.@sap/cds-dk— the CAP development toolkit: provides thecdsCLI for building, running, and deploying projects.@sap/hdi-deploy— the HDI deployer: reads compiled HANA artifacts fromdb/src/gen/and deploys them into the HDI container during the MTA build.
Run
npm ci(notnpm install) in CI/CD or when you first clone a project — it installs exactly the versions listed inpackage-lock.jsonrather than resolving fresh versions, which ensures reproducible builds. -
Version control with Git — what is the impact of using a local Git repository as we did in this tutorial?
Answer
A local Git repository gives you a full commit history, the ability to branch and experiment, and the safety net of reverting to any previous state. Every `git commit` is a snapshot of your project at a point in time.The limitation is that a local repo only exists on your BAS dev space. If the dev space is deleted or your BTP trial expires, that history is gone. In a real project you would push to a central repository (GitHub, GitLab, Azure DevOps, etc.) for:
- Backup — the code survives beyond any single environment
- Collaboration — multiple developers can push and pull changes
- CI/CD — pipelines can trigger automatically on commits and run builds, tests, and deployments
For ABAP developers in the room: Git-based version control in CAP works similarly to the abapGit / ABAP Development Tools (ADT) workflow you may already know, but operates at the file level rather than the transport level.
-
What is the difference between
npm installandnpm ci, and which should you use in a build pipeline?Answer
npm installresolves the dependency tree fresh frompackage.json, potentially installing newer minor or patch versions than the last run.npm ciinstalls exactly the versions locked inpackage-lock.json, deletesnode_modulesfirst if it already exists, and fails ifpackage-lock.jsonis missing or out of sync withpackage.json.In a build pipeline — including the
before-allhook inmta.yaml—npm ciis always preferred because it guarantees reproducible builds: every run installs exactly the same versions regardless of when the build runs or what has been published to the npm registry sincepackage-lock.jsonwas last updated.Use
npm installwhen you are intentionally updating dependencies and want npm to resolve fresh versions. Usenpm cieverywhere else. -
Look at the generated
package.json. What does thecds.requires.dbsection tell CAP about which database to use?Answer
The
cds.requires.dbblock is CAP's database configuration. By default the wizard generates something like:"cds": { "requires": { "db": { "kind": "sql" }, "[production]": { "db": { "kind": "hana" } } } }
"kind": "sql"tells CAP to use SQLite for local development — no HANA connection needed to runcds watchon your laptop. The"[production]"profile overrides this to"kind": "hana"when CAP is started with--profile production(whichcds build --productionactivates).At runtime on BTP, CAP reads the HDI container credentials from
VCAP_SERVICESusing thedbkey as the lookup name, so the service binding inmta.yamlmust be named to match. This single block controls both the local development database and the production HANA connection.
- Video Version of this Tutorial
- SAP Business Application Studio
- SAP HDI Containers
- HANA Cloud: HDI — Under the Hood
- CAP — Getting Started
- MTA Deployment Descriptor Reference
- Git basics in 10 minutes
Continue to 👉 Exercise 3 - Create Database Artifacts Using Core Data Services (CDS) for SAP HANA Cloud