Skip to Content

🟡 Devtoberfest 2025 - Coder's Challenge - CAP Documentation (Capire!)

Beginner
15 min.
You don't have to code all day. Let's have some fun with a little CAP challenge.
You will learn
  • CAP documentation, known as “Capire” (Italian for “understand”)
  • CAP and CDS
qmacroDJ AdamsSeptember 10, 2025
Created by
thecodester
September 10, 2025
Contributors
thecodester

Prerequisites

  • None

This challenge tests your basic knowledge and understanding of the SAP Cloud Application Programming Model, and hopefully will help you become more comfortable with its documentation, known as Capire.

The answers to each of these questions can be found in Capire, specifically in the topic page linked in the question. They will each be one word or phrase (optionally with instructions on how that phrase should be constructed) and must be precise and case-sensitive.

Good luck!

This challenge tutorial is part of our yearly and wonderful Devtoberfest, a month-long event filled with learning, fun, challenges, and prizes – for developers by developers.

Devtoberfest

For more info on Devtoberfest, see our Devtoberfest group page.

  • Step 1

    Topic page: Definition Language (CDL).

    Managed associations help us keep the details of relation and constraint mechanics out of our CDS models. With to-one managed associations, required foreign key elements can be automatically added. The name of such elements is constructed from the name of the source entity’s element, with the name of the target entity’s element, joined with an underscore, in a sort of source_target form.

    Consider the following CDS model:

    cds
    Copy
    using {cuid} from '@sap/cds/common';
    
    service Bookshop {
      entity Books : cuid {
        title  : String;
        author : Association to Authors;
      }
    
      entity Authors {
        key nr   : Integer;
            name : String;
      }
    }
    

    What would be the name of the foreign key element generated for the managed to-one association here?

     

  • Step 2

    Topic page: Definition Language (CDL).

    In CDS modeling, what is the CDL keyword used to declare named definitions that are to be used to extend entities?

    HINT: just by the way, there’s one of these types of named definitions (not explicitly declared, but) used in the CDS model above.

     

  • Step 3

    Topic page: Common Reuse Types.

    Instead of each project re-inventing their own definitions for common concepts that many of them share, CAP ships with a set of types, entities and more, that each project can use instead of cluttering up their domain models with their own versions.

    Entities such as Countries, Currencies, Languages and Timezones fall into this category and are themselves all extended with a common base definition which has name and descr elements.

    What is the name of that base definition?

     

  • Step 4

    Topic page: CDS-based Authorization

    Authorization restrictions can be added declaratively to CDS models via annotations (starting with the @ symbol). When compiled (or “mapped”) into EDMX, for an OData representation and conveyance of a given service, the metadata can also contain (OData flavor) annotations. Here’s an example of some annotations in EDMX, where there are three annotation terms that are applied to a Books entity target:

    xml
    Copy
    <Annotations Target="Bookshop.EntityContainer/Books">
      <Annotation Term="Capabilities.DeleteRestrictions">
        <Record Type="Capabilities.DeleteRestrictionsType">
          <PropertyValue Property="Deletable" Bool="false"/>
        </Record>
      </Annotation>
      <Annotation Term="Capabilities.InsertRestrictions">
        <Record Type="Capabilities.InsertRestrictionsType">
          <PropertyValue Property="Insertable" Bool="false"/>
        </Record>
      </Annotation>
      <Annotation Term="Capabilities.UpdateRestrictions">
        <Record Type="Capabilities.UpdateRestrictionsType">
          <PropertyValue Property="Updatable" Bool="false"/>
        </Record>
      </Annotation>
    </Annotations>
    

    These three annotations are in the OData Capabilities Vocabulary and are:

    • DeleteRestrictions
    • InsertRestrictions
    • UpdateRestrictions

    In other words, the only type of operation allowed on this entity is READ.

    There is single annotation in CDS that, when applied, is represented in OData EDMX as exactly this set of capability annotations. What is it (make sure you include the @ prefix when submitting your answer)?

    See A deep dive into CDS and OData annotations for further reading on this subject.

     

  • Step 5

    Topic page: Databases - Common

    The Providing Initial Data section of this topic page describes the ability to use CSV files to provide initial / sample data.

    According to this section, initial data (for configurations, code lists and similar) is picked up by default from data/ directories within the db/ directory. In contrast, sample data (for tests and demos) is picked up from data/ within a different parent directory, and is also excluded from production deployments.

    What is the name of this different parent directory?

     

  • Step 6

    Topic page: Query Language (CQL)

    CQL is a superset of SQL, and has many features that allow us to remain at a high level when thinking about how we can interact with our CDS models. One of these features is the concept of path expressions. Here are a few examples:

    In a select clause:

    sql
    Copy
    SELECT *, author.address.town.name from Books;
    

    In a where clause:

    sql
    Copy
    SELECT from Books where author.name='Emily Brontë'
    

    In a from clause:

    sql
    Copy
    SELECT from Authors[name='Emily Brontë'].books;
    

    In this last example, we see [name='Emily Brontë'] which is another feature of CQL. What is the two word phrase that describes what this feature is?

     

  • Step 7

    Topic page: Definition Language (CDL)

    As described in the Entities & Type Definitions section of this topic page, we learn that entities (named structured types usually representing data that is persisted and accessed via CRUD style operations) and types (simple, or structured, or as an association) can be defined in CDL.

    When defining entities or types, there is a keyword that can be used but is optional in both cases. What is that keyword?

     

  • Step 8

    Topic page: Common Annotations

    In an earlier question (Q4) we got to learn about a CDS annotation that maps to multiple annotations in the Capabilities Vocabulary (in the OData / EDMX context). There are other common annotations in CDS that map to annotations in other established vocabularies.

    For example, consider this CDS model definition:

    cds
    Copy
    service Bookshop {
      entity Books {
        @(
          title      : 'Identifier',
          description: 'A useless description'
        ) key ID : Integer;
        title    : String;
      }
    }
    

    The @title CDS annotation maps to the Common.Label annotation in EDMX, in other words to the Label term in the Common vocabulary, which happens to be a vocabulary from SAP.

    The @description CDS annotation maps to a different term in yet another vocabulary. What is the name of it, in Vocabulary.Term format?

     

  • Step 9

    Topic page: CDS Command Line Interface (CLI)

    One of the facets available in cds add is data, which helps with creating CSV headers and records for entity data.

    By default it will do this for all entities, but there’s an option (also sometimes known as a “switch”) with which you can limit the entities which are affected by providing a name to match on. What is this option?

     

  • Step 10

    Topic page: CDS Command Line Interface (CLI)

    The cds REPL is a super facility to interact with CAP’s JavaScript APIs in a comfortable and classic environment. To start up a CAP server when in the cds REPL, one can use the .run command.

    What is the command line equivalent option that can be used (when invoking cds repl) instead (you can answer with the short or long form version of this option)?

    See A reCAP intro to the cds REPL for further reading on the cds REPL.

     

Back to top