CAP
BTP & Integrationbeginner

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.

Explanation

SAP Cloud Application Programming Model (CAP) is an opinionated framework, plus a set of tools and libraries, for building services and applications on SAP Business Technology Platform. Before CAP, building a cloud-native SAP extension typically meant hand-wiring a Node.js or Java backend, manually writing OData services, manually integrating a database, and manually configuring authentication - each project reinventing the same plumbing. CAP standardizes this by giving developers a domain modeling language (Core Data Services, or CDS) and a generated runtime that turns declarative models into working, secure, cloud-ready services. At its heart, CAP separates concerns into three layers. First, the domain model, written in CDS, describes entities, their relationships, and business semantics - independent of any specific database or protocol. Second, the service layer, also written in CDS, defines what is exposed to consumers (which entities, which operations, which views of the data) and can carry authorization annotations. Third, the CAP runtime (available for Node.js and Java) takes these declarative artifacts and automatically generates OData V4 or REST APIs, wires up persistence (SAP HANA Cloud, SQLite for local development, or PostgreSQL), and applies cross-cutting concerns like authentication, authorization, input validation, and localization - without the developer writing boilerplate CRUD code. Why this matters commercially: CAP reduces time-to-market for BTP extension applications (side-by-side extensions to S/4HANA, standalone BTP applications, integration flows with custom logic) because teams focus on business logic and data modeling rather than infrastructure code. It also enforces a consistent architecture across projects, which matters when an SAP partner or internal COE needs to support many BTP applications with a small team. CAP is not a single deployable product; it is a development framework. The output of a CAP project is typically a set of microservices deployed to Cloud Foundry or Kyma (Kubernetes), packaged via multi-target application (MTA) descriptors, and bound to BTP services like SAP HANA Cloud, XSUAA (authorization/authentication), Application Logging, Destination service, and optionally SAP Event Mesh for asynchronous messaging. A typical CAP project structure includes a db/ folder with CDS data model files, a srv/ folder with service definitions and custom handler code (JavaScript/TypeScript or Java), an app/ folder for UI layers (Fiori elements, SAPUI5), and a package.json or pom.xml plus mta.yaml for build and deployment. Local development uses an in-memory SQLite database and a mocked authentication layer, so developers can iterate quickly before deploying to a real BTP subaccount. It is important to distinguish CAP from other SAP extensibility approaches: in-app extensibility on S/4HANA Cloud (using the Key User tools or ABAP Cloud in the same system) modifies or extends the existing system directly, while CAP-based side-by-side extensibility runs as an independent application on BTP that calls back into S/4HANA or other systems via APIs. Architects must choose based on lifecycle independence needs, performance requirements, and whether the extension logic needs to scale independently of the core ERP system. Understanding CAP's purpose and layering is the prerequisite for everything else in this topic: data modeling decisions, service exposure decisions, security configuration, and deployment topology all build on this mental model of domain model, service layer, and generated runtime.

Code example

ABAP Code
// db/schema.cds - a minimal CAP domain modelnamespace my.bookshop; entity Books { key ID   : Integer; title    : String(111); stock    : Integer; price    : Decimal(9,2); currency : Currency;} type Currency : String(3); // srv/cat-service.cds - exposing the model as an OData serviceusing my.bookshop as my from '../db/schema'; service CatalogService { @readonly entity Books as SELECT from my.Books;} // Running locally: `cds watch` starts the service with SQLite// and exposes an OData V4 endpoint at /odata/v4/catalog/Books

Real project scenario

A retail customer wants a lightweight BTP application that lets store managers check book stock levels and request replenishment, without touching their S/4HANA core system directly. The project team chooses CAP for a side-by-side extension: the domain model captures Books and StockRequests, the service layer exposes a read-only catalog API and a write API for replenishment requests, and a scheduled job later synchronizes confirmed requests back into S/4HANA via OData API calls. Because CAP generated the OData service and enforced role-based access automatically, the team delivered a working proof of concept within the first sprint and spent the remaining sprints on business logic and S/4HANA integration rather than API plumbing.

Common mistakes

โ€ข Treating CAP as just "a Node.js framework" and hand-writing custom CRUD logic instead of relying on the CDS-generated service handlers, which duplicates functionality and diverges from CAP's built-in validation and authorization. โ€ข Skipping the domain modeling phase and jumping straight to service definitions, leading to inconsistent entity semantics that are expensive to refactor later. โ€ข Assuming local development behavior (SQLite, mocked auth) will be identical to production behavior on SAP HANA Cloud and XSUAA, then being surprised by SQL dialect differences or authorization enforcement gaps. โ€ข Confusing CAP-based side-by-side extensibility with in-app S/4HANA extensibility, leading to an architecture decision that does not match the customer's lifecycle independence or upgrade requirements.

Best practices

โ€ข Start every CAP project with a clear, minimal domain model before writing any service or handler code. โ€ข Use `cds watch` and SQLite for fast local iteration, but validate against SAP HANA Cloud before considering a feature done. โ€ข Keep domain models (db/) and service exposure (srv/) conceptually separate so the same data model can back multiple services with different views and access rules. โ€ข Document early which BTP extensibility pattern (side-by-side vs in-app) was chosen and why, since this decision has long-term architectural consequences.

Interview angle

Interviewers commonly ask candidates to explain, in plain terms, what problem CAP solves and to describe its three-layer architecture (domain model, service layer, runtime). A strong answer distinguishes CAP as a development framework (not a deployable product itself), names the supported runtimes (Node.js, Java), and can articulate when CAP-based side-by-side extension is preferable to in-app extensibility - a decision architects are frequently asked to justify.