Provision a HANA Cloud free tier instance, configure cds build --for hana, and connect from local dev.
cds deploy --to hanaHANA Cloud is the production database for CAP apps on BTP. HDI is the deployment model that keeps schema changes safe, repeatable, and auditable — understanding it prevents the common mistakes that cause deployments to fail.
┌─────────────────────────────────────────┐
│ SAP HANA Cloud │
│ │
│ ┌─────────────┐ ┌────────────────┐ │
│ │ System DB │ │ Tenant DB │ │
│ │ (admin) │ │ (your app) │ │
│ └─────────────┘ │ │ │
│ │ ┌──────────┐ │ │
│ │ │ HDI │ │ │
│ │ │ Container│ │ │
│ │ └──────────┘ │ │
│ └────────────────┘ │
└─────────────────────────────────────────┘
HDI (HANA Deployment Infrastructure) manages design-time vs runtime artifacts:
| Design-time (your code) | Runtime (HDI deploys) |
|---|---|
.hdbcds / .hdbtable files |
Tables in HANA |
.hdbview files |
Views |
.hdbprocedure files |
Stored procedures |
.hdbsequence files |
Sequences |
CAP runs cds build --for hana to generate these from your CDS model, then HDI deploys them.
# Create HANA Cloud service instance (if via CF CLI)
cf create-service hana-cloud hana myapp-hana \
-c '{"data": {"edition": "cloud", "memory": 30, "systempassword": "YourPassword1"}}'
# Create a service key for local development
cf create-service-key myapp-hana myapp-hana-key
cf service-key myapp-hana myapp-hana-key
# Copy credentials to local .env (never commit!)
cat > .env << 'EOF'
VCAP_SERVICES={"hana":[{"credentials":{"host":"...","port":"443","user":"...","password":"...","schema":"..."}}]}
EOF
// .cdsrc.json
{
"requires": {
"db": {
"[development]": {
"kind": "hana",
"vcap": { "label": "hana" }
}
}
}
}
# Build CDS → HANA artifacts
cds build --for hana
# Deploy to HANA Cloud (uses .env credentials)
cds deploy --to hana
# Or use HDI deployer (production)
npm run deploy
cds build --for hana generates:
gen/
└── db/
├── src/
│ ├── gen/
│ │ ├── Books.hdbcds
│ │ └── Authors.hdbcds
└── package.json
# In HANA Database Explorer
SELECT TABLE_NAME FROM TABLES WHERE SCHEMA_NAME = CURRENT_SCHEMA;
-- Should list: BOOKS, AUTHORS, ORDERS, etc.
# Or via cds REPL
cds repl --profile development
> const db = await cds.connect.to('db')
> await db.run(SELECT.from('Books').limit(3))
| Mistake | Symptom | Fix |
|---|---|---|
| IP not in allowlist | Connection timeout | Add your IP in HANA Cloud cockpit |
| Wrong credentials in .env | Auth failure | Regenerate service key |
| Schema not created | Table not found | Run cds deploy --to hana |
| CAP version mismatch | Build errors | npm update @sap/cds |
.envcds build --for hana and inspect the gen/db/ outputcds deploy --to hana and open HANA Database Explorer to verify tables.env as VCAP_SERVICES — never commit this filecds build --for hana generates .hdbcds files; cds deploy --to hana applies them