SampleSampletypeA worked example you read or clone. Evidence: it demonstrates, it never provides.See every one →What this type is →by SAPby SAPoriginPublished by SAP itself. A visible facet, never an input to a reading — a dormant official plugin reads exactly like a dormant independent one.See every one →Starting point

SAP-samples/cap-cds-hands-on

A hands-on, five-part workshop on CAP's Conceptual Definition Language, from a first entity definition through types, aspects, associations and compositions to annotations and declarative constraints.

Fifteen exercises across five parts build a CDS model from a single entity definition up through custom types, aspects, associations and compositions, then expose it via a service and add annotations and declarative constraints. Originally written for a UKISUG Connect 2025 hands-on session, it has since been extended, and it assumes no prior CDS or CAP experience. It stays inside the db/ and srv/ layers of a CAP project rather than covering deployment or a UI.

Facts

Last pushLicenceApache-2.0

Where it sits

Lives in
Demonstrates
Data modellingCAPData modellingcapabilityDefining the shape of data before anything serves it: entities and their types, how they relate, and the projections and views that services and applications consume.
Flavors

Who is behind it

SAP SamplesSAP SamplesOrganisationMaintains this
In the atlas: maintains 222
@SAP-samples
maintainerDJ AdamsPersonContributes to this
Developer Advocate
In the atlas: contributes to 20, wrote 22
@qmacro
1 contributor

What it declares

Every artifact

Type
Sample
Origin
By SAP

As a sample

Form
Workshop or CodeJam material

Connections1

SAP-samples/cap-cds-hands-on connectionsSAP-samples/cap-cds-hands-onPROVIDES→ demonstrates1demonstrates authoredData modelling

README

quoted from SAP-samples/cap-cds-hands-on under Apache-2.0, read
SAP-samples/cap-cds-hands-on/README.mdOn GitHub

REUSE status

Hands-on with CAP CDS

Gain a thorough grounding in CAP CDS modelling.

Introduction

In this hands-on workshop you'll become familiar and comfortable with the key features of CDS modelling, primarily focusing on the Conceptual Definition Language (CDL), the predominantly declarative domain-specific language (DSL) in the CDS family. You'll explore the different concepts that make CAP such a compelling framework for today's world of AI, where concision, correctness and the imperative to write less code is at the forefront of everyone's mind.

No prior experience is required, and this workshop is suitable for non-developers as well as developers. All you need is curiosity and a desire to learn!

This workshop was originally written for a hands-on session at UKISUG Connect 2025 (see Hands-on domain modelling with CAP's CDS at UKISUG Connect), but has now been significantly extended.

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.

The exercises presume no prior knowledge; nor do they attempt to cover everything there is to know about CDS modelling and CDL. For that, see the relevant sections of Capire, particularly the CDS topic.

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.

Part 1 - Understanding the context and some basic definitions

When, where and why does one use CDL? To define CDS models that reflect the problem domain, the business entities that make up the solution landscape. Who is responsible for this? Teams of developers and business domain experts combined; between them the domain knowledge can be accurately expressed and modelled as the foundation for a service, solution or application.

The exercises in this part help us understand better the context of domain modelling with CDS.

Part 2 - More on structure with types, aspects and reuse

The definition we have so far is deliberately very basic. What facilities in CDL are available to expand on that? What about the definition of custom types to bring consistency and at the same time avoid repetition? Perhaps most importantly, how can we define our domain models in a way that reuse is always possible, both in and of what we are building?

In this part we'll expand our basic definitions as a way of learning about the answers to these questions.

Part 3 - Describing relationships with associations and compositions

At this point in the workshop we have a couple of entities, representing products and suppliers. But they're completely separate from one another, with no relation between them.

In this part we'll look at the facilities in CDL for describing relationships, and add a conjoined pair of entities to see how they are are manifested and behave.

Part 4 - Exposing models via services - interfaces for the outside world

Thus far the vast majority of work, and all of the focus, has been at what we understand by now to be the db/ layer - the core entity definitions and relationships between them. While we've dabbled briefly with a service definition, that was just a means to an end, to allow us to look at our model constructions through the lens of the OData V4 standard.

In this part we'll turn our focus to the srv/ layer and look at why it's separate and start to explore what we can do there.

Part 5 - Annotations and solid state programming

With the decent grounding in CDS modelling that we have at this point, we can turn to further features that make CAP the powerful, declarative and concise framework that it is.

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) 2025 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.

Apache-2.0, read

Details

Sources3
Added by handdiscovered herechecked
github.com/SAP-samples/cap-cds-hands-ontree, pushes, contributors, CIchecked
README.mdquoted, and what the entry declareschecked

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
discovered viaAdded by hand
first seen in the atlas
ecosystem and domaincap, data-and-persistence
Flavors1
Node.js
“CAP Node.js.” — SAP-samples/cap-cds-hands-on — READMEchecked
Contributors1

From the repository’s contributor list, .

History in the atlas1
  1. First seen.
For your agent
Ref
artifact:sap-samples-cap-cds-hands-on
JSON
/artifacts/sap-samples-cap-cds-hands-on.json
MCP
Connecting an agent