SAP Cloud Application Programming Model (CAP)
The SAP Cloud Application Programming Model (CAP) is SAP's framework for building enterprise services and applications, mainly on SAP BTP. Developers declare data models and services in CAP's own Core Data Services (CDS) language, and a Node.js or Java runtime serves them as OData, REST or GraphQL endpoints, with generic handlers for standard operations.
Quick facts
- Type
- Application framework (languages, libraries, tools)
- Layer
- Business logic & data model, on the SAP BTP platform lane
- Runtimes
- Node.js and Java
- Databases
- SQLite or H2 for development; SAP HANA Cloud or PostgreSQL for production
- Deployed to
- SAP BTP, Cloud Foundry or Kyma runtime
- Tools
- CDS command line, Visual Studio Code, SAP Business Application Studio
- Applies to
- SAP BTP (side-by-side with SAP S/4HANA, any edition)
Layer: Business logic & data modelWhere it sits ▾
How does a CAP application work?
A CAP application starts from declarations and adds code only where the framework's defaults are not enough:
- Domain model: entities, types and associations are written in CDS files, for example suppliers and delivery slots for an Alder Manufacturing logistics app.
- Services: service definitions expose projections of those entities, shaped for a UI or an API.
- Runtime: the Node.js runtime or the CAP Java SDK serves the services and handles standard operations generically: reading, writing, paging, sorting and SAP Fiori draft.
- Custom logic: event handlers in JavaScript, TypeScript or Java, registered for the before, on and after phases of a request, add validations, calculations and calls to other systems.
- Persistence: the same model runs on SQLite or H2 during development and on SAP HANA Cloud or PostgreSQL in production.
- Deployment: the application is deployed to SAP BTP, on the Cloud Foundry or Kyma runtime.
SAP Fiori elements apps consume CAP services through UI annotations written in the same CDS files. A CAP application is therefore mostly model, with code concentrated where the business logic is specific.
Is CAP CDS the same as ABAP CDS?
No. Both come from SAP's Core Data Services idea, both use a similar declarative syntax and both carry annotations, but they are separate implementations:
- ABAP CDS is part of the ABAP platform. Its views are repository objects activated as database views inside an ABAP system and transported with ABAP transports.
- CAP CDS is CAP's modeling language. Its compiler turns models into a JSON-based representation called Core Schema Notation (CSN), from which CAP generates database artifacts and service metadata.
Annotations show the difference in practice. In CAP, UI annotations use the OData term names directly, such as UI.LineItem; in ABAP CDS, element-level notations such as @UI.lineItem are translated into those terms when the service is exposed. A model cannot be moved from one to the other unchanged. CAP CDS and ABAP CDS share a name and a philosophy, not a runtime.
When is CAP the right choice?
Choose CAP when:
- the application belongs beside SAP S/4HANA, not inside it, as a side-by-side extension on SAP BTP;
- the application owns its own data or combines data from several systems, SAP and non-SAP;
- the team works in JavaScript, TypeScript or Java rather than ABAP;
- the application must serve several customers as a multitenant SaaS offering, which CAP supports with tenant isolation and its MTX services.
Prefer RAP when the logic must run in the same transaction as SAP S/4HANA data, when the extension changes a standard business object, or when the team and the operations model are ABAP-based.
Many landscapes use both: RAP for logic close to the core, CAP for applications around it. The deciding question for CAP is where the data and the transaction belong.
How does CAP connect to SAP S/4HANA?
A CAP application does not run inside SAP S/4HANA, so it reaches SAP data through APIs:
- The API definition of an SAP S/4HANA OData service, for example from the SAP Business Accelerator Hub, is imported into the CAP project with cds import, which reads OData EDMX, OpenAPI and AsyncAPI files.
- During development, CAP can mock the imported service locally, so teams can work before the connection exists.
- In production, calls go through SAP BTP connectivity: destinations for the target system and, for on-premise systems, the Cloud Connector.
- Events from SAP S/4HANA can trigger CAP logic asynchronously where the scenario supports them, typically through an SAP event broker service.
The released API, not the database table, is the contract between CAP and SAP S/4HANA. This keeps the extension decoupled from the core, which is the purpose of the side-by-side approach CAP follows.
Where does CAP stop?
CAP's strengths are speed and consistency. Generic handlers remove boilerplate, local development works without a cloud connection thanks to mocks and SQLite, SAP Fiori and SAP HANA support are built in, and multitenancy is part of the framework instead of a project of its own.
The limits come from running outside the system of record:
- No direct access to SAP S/4HANA internals. Everything goes through released APIs; missing APIs become blockers or need an ABAP-side complement.
- No shared transaction. A CAP update and an SAP S/4HANA posting are separate transactions; failure handling must be designed explicitly.
- More to operate. A CAP application adds an SAP BTP runtime, a database and connectivity to the landscape, with their own monitoring, upgrades and costs.
- Opinionated framework. Working against CAP's conventions costs more than following them.
CAP is the stronger choice for applications beside the core; it does not replace logic that must live inside it.
CAP vs. RAP vs. ABAP CDS: what is the difference?
| CAP | RAP | ABAP CDS | |
|---|---|---|---|
| What it is | Framework for services and applications | ABAP programming model for transactional apps and services | Data modeling language of the ABAP platform |
| Runs on | Mainly SAP BTP (Node.js or Java) | ABAP systems: SAP S/4HANA, SAP BTP ABAP environment | ABAP systems |
| Data model | CAP CDS | ABAP CDS view entities | Is the data model |
| Transactional behavior | Generic handlers plus custom handlers | Behavior definitions and behavior pools | None (read model) |
| Typical use | Side-by-side extensions and SaaS on SAP BTP | Apps and APIs next to SAP S/4HANA data | Data models, analytics, API foundations |
CAP and RAP are alternatives for building services in different places; ABAP CDS is a building block of RAP, not an alternative to CAP.
FAQ
Is CAP only for SAP BTP?
CAP is designed for SAP BTP, and SAP documents deployment to the Cloud Foundry and Kyma runtimes. Development also runs locally on a laptop with SQLite and mocked services. Operating CAP applications outside SAP BTP is not covered by this guide.
Does CAP support OData V2 as well as OData V4?
CAP defaults to OData V4. OData V2 is deprecated in CAP and served through the OData V2 adapter, a plugin in Node.js and a built-in adapter in CAP Java, for existing V2-based UIs. OData V4 is the choice for new SAP Fiori elements apps.
Can CAP build SAP Fiori elements apps?
Yes. UI annotations are written in CAP CDS files, CAP serves the OData service and handles SAP Fiori draft generically, and SAP Fiori tools generate list report and object page apps on top of the CAP service.
Which databases does CAP support?
SAP documents SQLite and H2 for development and SAP HANA Cloud or PostgreSQL for production. Switching between them is mostly a configuration profile change, because the data model is written in CDS rather than in database-specific SQL.
Can CAP read SAP S/4HANA tables directly?
No. A CAP application consumes SAP S/4HANA through released APIs, such as OData services, called through SAP BTP connectivity. Direct table access would bypass the stability contract that keeps a side-by-side extension upgrade-safe.
Sources
- SAP Help Portal: Developing with the SAP Cloud Application Programming Model (SAP BTP)
- SAP Help Portal: Programming Models on SAP BTP (CAP and ABAP Cloud)
- SAP Help Portal: SAP BTP, Cloud Foundry and Kyma runtimes with CAP
- CAP documentation (capire): Features Overview
- CAP documentation (capire): Serving OData APIs (V4 default, V2 support)
- Applies to
- SAP BTP
- Last reviewed