CAP
The SAP Cloud Application Programming Model (CAP) is a framework and toolset for building enterprise-grade services and applications on SAP BTP. This topic covers CAP's core concepts (CDS data modeling, service definitions, and the CAP runtime), how projects are structured and deployed to Cloud Foundry or Kyma, how CAP applications integrate with SAP systems and BTP services (HANA, XSUAA, destinations, event mesh), and the operational, security, and troubleshooting considerations consultants and architects need for production-grade CAP-based solutions.
Overview
The SAP Cloud Application Programming Model (CAP) is a framework and toolset for building enterprise-grade services and applications on SAP BTP. This topic covers CAP's core concepts (CDS data modeling, service definitions, and the CAP runtime), how projects are structured and deployed to Cloud Foundry or Kyma, how CAP applications integrate with SAP systems and BTP services (HANA, XSUAA, destinations, event mesh), and the operational, security, and troubleshooting considerations consultants and architects need for production-grade CAP-based solutions.
Lessons in this topic
- BTP CAP Part 1: What CAP Is and Why It Matters on SAP BTPThe 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.
- BTP CAP Part 2: Building and Exposing Services with CDSDesign CAP services: projections on domain entities, service-level exposure choices (read-only, restricted fields), annotations for OData and UI, mock data, hybrid testing against real BTP services with cds bind, and database deployment with cds deploy.
- BTP CAP Part 3: Securing CAP Services with XSUAA Role-Based AuthorizationSecure CAP declaratively: @requires and @restrict annotations for roles and instance-based conditions, generating xs-security.json with cds compile, mocked users for local testing, XSUAA in production, and testing authorization in hybrid mode.
- BTP CAP Part 4: Multitenancy, Extensibility and Production DeploymentBuild SaaS with CAP: multitenancy with the MTX services (@sap/cds-mtxs), tenant subscription via SaaS registry, tenant-specific HDI containers, tenant-aware caching, extensibility for customers, and production deployment practices (MTA, profiles, CI/CD).
- BTP CAP Part 5: Domain Modeling with Entities, Associations, Compositions and AspectsModel the domain well in CDS: entities with keys (cuid), reusable aspects (managed, temporal), types and code lists, associations (references) vs compositions (contained children with deep insert/delete), and modeling patterns that keep services and UIs simple.
- BTP CAP Part 6: Service Handlers — Before, On, After and TransactionsAdd business logic the CAP way: event handlers in before, on and after phases, validations with req.error/req.reject, enriching results, calling other services and remote APIs, transaction handling with cds.tx, and avoiding the anti-pattern of replacing generic handlers.
- BTP CAP Part 7: OData Services, Actions, Functions and DraftExpose rich OData V4 services with CAP: bound and unbound actions and functions, draft-enabled entities for Fiori elements editing (@odata.draft.enabled), side effects and value helps via annotations, and pitfalls with draft (validation timing, handlers on drafts).
Interview questions covered
- What are the core concepts of CAP, and how would you explain them clearly in an SAP interview?
- How would you apply CAP in a real SAP project? Walk through the design or implementation approach.
- A production issue is reported in CAP. What would you check first, and how would you troubleshoot it systematically?
- What are the most important design decisions, trade-offs, and best practices in CAP?
- Suppose you inherit an existing CAP solution. How would you review it before making a change?
- A Fiori elements app on CAP needs approval actions and multi-step editing. How do you design the OData service?
- Secure a CAP app so viewers read only their country's data and admins manage everything.
- A retail customer wants a custom store-audit app on BTP. Explain why you'd use CAP and how you'd start.
- Design CAP services for a catalog app used by end users and administrators.
- An order-management CAP model causes accidental data loss and complex services. How do you improve the domain model?
- Custom CAP handlers broke Fiori paging and filtering, and a remote call per row made reads slow. How do you restructure the logic?
- You are turning a CAP app into a multitenant SaaS offering. What do you design?
How to study CAP
CAP has 7 lessons (1 beginner, 3 intermediate, 3 advanced) with about 33 minutes of reading in total. Start with the lesson that matches your level, then read the real project scenario and common mistakes in each one before moving on. After the lessons, say the 12 interview questions out loud in your own words, then check yourself against the model answer in each question (shown once you open it). Use the 22 mock questions to check recall.
Mock test questions covered
Try answering each one before you open the mock test; the answer options and scoring are in the Mock Questions tab.
- Where does each subscriber tenant's data live in a multitenant CAP app on HANA Cloud?
- Which aspect from @sap/cds/common adds created/modified timestamps and users?
- Which handler phase is best for input validation in CAP?
- What is the difference between an OData action and function in CAP?
- Handlers for draft edits are not triggered. What might be overlooked?
- Authorization checks were written in handler if-statements and one was missed. What is the recommended approach?
- In the SAP Cloud Application Programming Model (CAP), which domain-specific language is primarily used to define data models and service definitions?
- In a CAP Node.js service implementation, what is the correct execution order of the event handler phases for a single incoming request?
- When a CAP service is served without any explicit protocol configuration, which OData protocol version is exposed by default?
- What is the key distinguishing behavior of a 'composition' relationship compared to an 'association' in a CDS data model?
- Which CAP feature/package provides multitenancy and SaaS extensibility capabilities such as tenant-specific model extensions and subscription handling?
- When a CAP project is started locally without any additional persistence configuration, which database is used by default to store data?
- A Fiori app needs multi-step editing without validation errors at every field change. What should be used?
- Custom on-READ handlers for every entity broke $filter and paging. What is the better approach?
- Deleting an order also deleted addresses still used by customers. What modeling error caused this?