Use cds init to create a new CAP project, add a sample service, and explore the generated folder structure.
CAP (Cloud Application Programming Model) lets you build OData services with very little boilerplate.
cds --version
# @sap/cds-dk: 8.x.x
If not installed:
npm install -g @sap/cds-dk
cds init bookshop
cd bookshop
bookshop/
├── app/ ← SAPUI5 / Fiori frontends go here
├── db/ ← CDS data model files (.cds)
├── srv/ ← Service definitions (.cds) and handlers (.js)
├── .cdsrc.json ← CDS configuration
└── package.json
Create db/schema.cds:
namespace bookshop;
entity Books {
key ID : Integer;
title : String(100);
author : String(50);
stock : Integer;
price : Decimal(10, 2);
}
Create srv/cat-service.cds:
using bookshop from '../db/schema';
service CatalogService {
entity Books as projection on bookshop.Books;
}
Create db/data/bookshop-Books.csv:
ID,title,author,stock,price
1,The Hobbit,J.R.R. Tolkien,100,14.99
2,Dune,Frank Herbert,75,12.50
3,Foundation,Isaac Asimov,50,11.99
cds watch
Visit http://localhost:4004 — you'll see your OData service metadata and the Books entity.
cds add samples adds the full Bookshop samplecds add hana wires up SAP HANA as the database (instead of SQLite in dev)cds add approuter adds an AppRouter for BTP deployment