SAP-samples/cap-tour-hands-on
An eight-exercise tour of CAP features: mocked auth and messaging, the cds REPL, plugin authoring, status-transition flows, testing, declarative constraints and API client packages.
Each exercise is a self-contained look at one CAP facility: mocking authentication and file-based local messaging, using the cds REPL, writing a plugin, exploring status-transition flows released toward the end of 2025, testing a service, adding declarative constraints, and exporting an API client package from a CDS service definition for a consumer project. The exercises build on a shared Northwind-based base project rather than starting fresh each time. A showurls helper is included for reading the localhost URLs a given exercise's README names, useful in GitHub Codespaces where they are auto-exposed under custom domains.
Facts
Where it sits
Who is behind it
In the atlas: maintains 222@SAP-samplesmaintainerDJ AdamsContributes to this
Developer Advocate
In the atlas: contributes to 20, wrote 22@qmacroThomas JungContributes to this
Developer Advocate
In the atlas: contributes to 15, wrote 6@jung-thomas2 contributors
What it declares
Every artifact
- Type
- Sample
- Origin
- By SAP
As a sample
- Form
- Workshop or CodeJam material
Connections
Running the whole stack on a laptop against real bindings
Writing a package that extends a framework or runtime
Download
README
quoted from SAP-samples/cap-tour-hands-on under Apache-2.0, readA hands-on tour of CAP
Explore some of CAP's facets, features & facilities in this series of hands-on exercises.
Introduction
In this hands-on workshop you'll explore various developer and design-time focused features of CAP, the domain expert and developer centric framework for modern SAP development.
Prerequisites
In order to work through the exercises, you'll need a development environment for CAP Node.js. See the prerequisites info page for details and options.
Exercises
To get started, clone this repository and open it in your favourite editor or IDE. Alternatively, launch a GitHub Codespace directly from this repository - see the prerequisites for more info.
-
With the mocked authentication strategy, we can embrace and work on the important aspect of securing our app or service right from the very start. CAP makes it easy to do the right things here.
In this exercise we'll look at how we can do that, based on a simple service.
-
In the blog post "Five reasons to use CAP" we see that everything is an event. Whether synchronous, such as via HTTP requests and responses for OData operations, or asynchronous, where messages are emitted and received for decoupled service-to-service communications.
The Messaging topic in Capire has a great overview and an explanation of all the different message brokers that can be used. And there's one that is well suited for local-first development: file based messaging, which we'll explore in this exercise.
-
In any language or development environment, having a REPL is a superpower, and it pays to embrace it and be at least a little familiar with it. CAP as a whole is built on solid foundations and practices that have matured over the decades, and the REPL is part of that, first appearing in the 1960's and initially popularised in the LISP and LISP-derivative language communities.
Node.js has a REPL, and it is upon this REPL that the cds REPL is based. In this exercise, we'll explore the cds REPL.
-
The plugin concept is fundamental to the CAP framework. Not only as a clean and simple extension mechanism, but also a core building block in the framework itself. Various basic components in CAP are implemented as plugins, as well as many additional features.
In this exercise we'll implement a simple plugin so that we understand how they're put together and how they work.
-
05 - Exploring status-transition flows
Released towards the end of 2025, status-transition flows moves us one step closer to declarative nirvana, and in the right direction with regards to LLM-based learning about CAP powered solutions, a smaller code surface area, and a shift left of logic and definitions.
In this exercise we'll get a feel for status-transition flows by exploring a simple implementation.
-
In the previous exercise we checked the behaviour of our service definition by starting the CAP server and then manually sending HTTP requests to it. This is a great way to interact, but no the only one.
In this exercise we'll add tests which will put our service through its paces. We'll do that first by exploring in the cds REPL and then formalising our explorations in a file that we can drive with a test runner.
-
07 - Defining constraints declaratively
CDS modelling doesn't stop at entities, relationships and service exposure. Domain design also includes constraints, and these can be included in the overall model declaratively, meaning a cleaner and smaller surface area (less chance of bugs), a shared understanding of intent between the domain expert and developer and less code to write and maintain.
In this exercise, we'll explore declarative constraints by adding some to our Northwind-based base project.
-
08 - Discovering API client package export and reuse
CAP-level service integration (Calesi) is a powerful and flexible concept and exists in various forms. One of these is the idea of API client packages which can be created from CDS service definitions, exported, and then used in consumer projects.
In this exercise we'll explore what that is, and how it works.
Utilities
The utils/ directory contains a small showurls helper that emits
the http://localhost:4004... URLs found in a given exercise's README, which
is handy in GitHub Codespaces where localhost addresses are auto-exposed with
custom domain names. Use the variant that matches your shell, passing the
exercise number as the argument:
- macOS / Linux / Codespaces:
./utils/showurls 1 - Windows (PowerShell):
.\utils\showurls.ps1 1 - Windows (cmd):
utils\showurls.cmd 1
All three produce identical output.
Support
Support for the content in this repository is available during the actual time of the workshop event for which this content has been designed.
License
Copyright (c) 2026 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
Contributors
History in the atlas
- First seen.
For your agent
- Ref
artifact:sap-samples-cap-tour-hands-on- JSON
- /artifacts/sap-samples-cap-tour-hands-on.json
- MCP
- Connecting an agent