Subject: SAP-Business-Application-Studio
The Cloud Application Programming (CAP) model by SAP provides a streamlined framework for building enterprise-grade, cloud-ready applications. One of the fundamental aspects of CAP is its powerful and flexible data modeling and persistence layer, which enables developers to work efficiently with databases.
When developing CAP applications in SAP Business Application Studio (SAP BAS), understanding how to define, manage, and interact with databases is key to delivering scalable and maintainable services.
CAP abstracts database interactions by leveraging Core Data Services (CDS) for data modeling and a persistence layer that can connect to different database engines. The framework supports:
CAP handles data access, CRUD operations, and transaction management, enabling developers to focus on business logic.
cds command-line tool or project templates.db folder containing your data model files (.cds).db/data-model.cds:namespace my.bookshop;
entity Books {
key ID : UUID;
title : String;
author : String;
stock : Integer;
}
This model defines a Books entity with basic attributes.
CAP automatically maps CDS entities to database tables.
@sap/cds-sqlite).package.json and .env file with HANA connection details.CAP provides an API to perform CRUD operations on entities:
Example querying books in a service implementation:
const cds = require('@sap/cds');
module.exports = cds.service.impl(async function() {
const { Books } = this.entities;
this.on('READ', Books, async () => {
return SELECT.from(Books).where({ stock: { '>': 0 } });
});
});
cds deploy to generate and deploy tables.Working with databases in CAP applications within SAP Business Application Studio provides a productive and flexible development experience. Through declarative CDS models, adaptable persistence layers, and seamless integration with SAP HANA and other databases, CAP empowers developers to build robust and scalable data-driven applications efficiently.
Leveraging SAP BAS’s tooling and connectivity makes database management straightforward, from local prototyping to enterprise-grade cloud deployments.