BTP CAP Part 1: What CAP Is and Why It Matters on SAP BTP
The SAP Cloud Application Programming Model (CAP) is SAP's framework for building enterprise services and apps on BTP with Node. js or Java. Learn its idea — model with CDS, get services and persistence generated, add custom logic only where needed — the project structure, local development with cds watch, and how it deploys to BTP.
What this complete series covers
Learn CAP in a clear, practical sequence — from the basic idea to real project use, troubleshooting, and interview-ready understanding.
- Who it is for
- Best for SAP consultants, developers, and learners who want a practical understanding of CAP.
- Prerequisites
- A basic understanding of SAP BTP helps. Hands-on steps may require a BTP subaccount and access to the relevant Integration Suite or BTP service.
- Final outcome
- By the end, you should be able to explain CAP clearly, follow the main end-to-end flow, apply it in a project scenario, and troubleshoot the most common issues.
- Part 1: BTP CAP Part 1: What CAP Is and Why It Matters on SAP BTP
An introduction to the SAP Cloud Application Programming Model: what problem it solves, its core building blocks, and where it fits in the SAP BTP application development landscape.
- Part 2: BTP CAP Part 2: Building and Exposing Services with CDS
A practical walkthrough of designing CDS data models, defining services with projections and annotations, and understanding how CAP turns these declarations into a running OData/RE
- Part 3: BTP CAP Part 3: Securing CAP Services with XSUAA Role-Based Authorization
Learn how CAP services enforce authentication and authorization using the XSUAA service, restrict-based annotations, and scopes, and how this model differs from classic ABAP authorization objects.
- Part 4: BTP CAP Part 4: Multitenancy, Extensibility and Production Deployment
Design SaaS CAP applications for tenant isolation, tenant-aware persistence, subscription lifecycle, extensibility and production operations instead of treating multitenancy as a deployment flag.
- Part 5: BTP CAP Part 5: Domain Modeling with Entities, Associations, Compositions and Aspects
Model CAP services around business domains using CDS entities, associations, compositions and reusable aspects rather than designing persistence tables first.
- Part 6: BTP CAP Part 6: Service Handlers — Before, On, After and Transactions
Use CAP event handlers deliberately: before for validation/defaulting, on for custom operation handling, after for result enrichment, while respecting CAP request transactions.
- Part 7: BTP CAP Part 7: OData Services, Actions, Functions and Draft
Expose CAP domain services through OData with explicit actions and functions and use draft-enabled entities when long-running Fiori editing requires persisted intermediate state.
System and release assumptions: SAP BTP services evolve regularly. Capability names, screens, and setup steps can differ by region, entitlement, and tenant version; the core design principles remain the same.
Explanation
📌 KEY POINTS
✅ CAP = CDS models (data + services) + generic runtime providers + your custom handlers.
✅ Project layout: db/ (domain model), srv/ (services, handlers), app/ (UIs).
✅ cds watch runs locally with an in-memory SQLite database and serves OData automatically.
✅ cds add adds production features (hana, xsuaa, mta, multitenancy) for BTP deployment.
⚠️ Writing custom code for what CAP provides generically (CRUD, paging, filtering) adds bugs and maintenance.
━━━━━━━━━━━━━━━━━━━━
▶ WHAT THIS SERIES COVERS
Part 1: What CAP is
Part 2: Building and exposing services
Part 3: Securing services
Part 4: Multitenancy and production deployment
Part 5: Domain modeling in depth
Part 6: Service handlers and transactions
Part 7: OData services, actions, functions and draft
━━━━━━━━━━━━━━━━━━━━
▶ 1. PHILOSOPHY
- Model first; generic providers; code only for business logic.
━━━━━━━━━━━━━━━━━━━━
▶ 2. PROJECT STRUCTURE
- db, srv, app, package.json.
━━━━━━━━━━━━━━━━━━━━
▶ 3. LOCAL DEVELOPMENT
- cds watch, SQLite, mock data (CSV).
━━━━━━━━━━━━━━━━━━━━
▶ 4. SERVICES
- OData V4 by default; also REST/GraphQL adapters.
━━━━━━━━━━━━━━━━━━━━
▶ 5. DEPLOYMENT
- HANA Cloud, XSUAA, MTA to Cloud Foundry (or Kyma).
━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP
- cds init bookshop && cd bookshop.
- Add an entity in db/schema.cds and a service in srv/.
- Run cds watch and open the service.
✅ CHECKPOINT: GET /odata/v4/catalog/Books returns data.
Code example
===== START =====npm i -g @sap/cds-dkcds init bookshop && cd bookshopcds watch # http://localhost:4004 ===== db/schema.cds =====namespace my.bookshop;using { cuid, managed } from '@sap/cds/common';entity Books : cuid, managed { title : String(111); stock : Integer; } ===== srv/cat-service.cds =====using my.bookshop as my from '../db/schema';service CatalogService { entity Books as projection on my.Books; } ===== PRODUCTION =====cds add hana,xsuaa,mta && mbt build && cf deploy mta_archives/*.mtarReal project scenario
A retail customer wanted a custom app for store audits. With CAP, a working OData service with persistence ran locally on day one; the team focused on validation logic and a Fiori elements UI instead of plumbing.
Common mistakes
- Custom CRUD code.
- Hand-written SQL everywhere.
- Skipping local testing.
- No mock data.
- Deploying manually.
Best practices
- Model first.
- Use generic providers.
- cds watch for fast feedback.
- CSV test data.
- MTA-based deployment.
Interview angle
Questions: "What is CAP?", "What does cds watch do?", "How do you deploy CAP to BTP?"
Strong answer: CDS models, generic providers, structure, local dev, deployment.
Practice this lesson
Quick check
1. What is the primary purpose of running the 'cds watch' command during local CAP development?
2. What is the core idea of SAP CAP?
3. In the SAP Cloud Application Programming Model (CAP), which domain-specific language is primarily used to define data models and service definitions?
Interview questions
1. A retail customer wants a custom store-audit app on BTP. Explain why you'd use CAP and how you'd start.
Answer it in your own words first, then compare.
2. What are the core concepts of CAP, and how would you explain them clearly in an SAP interview?
Answer it in your own words first, then compare.
Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.
More lessons in this topic
- BTP CAP Part 2: Building and Exposing Services with CDS
- BTP CAP Part 3: Securing CAP Services with XSUAA Role-Based Authorization
- BTP CAP Part 4: Multitenancy, Extensibility and Production Deployment
- BTP CAP Part 5: Domain Modeling with Entities, Associations, Compositions and Aspects
- BTP CAP Part 6: Service Handlers — Before, On, After and Transactions
- BTP CAP Part 7: OData Services, Actions, Functions and Draft