The SAP Cloud Application Programming Model (CAP) is a modern framework designed to simplify the development of enterprise-grade applications on SAP Business Technology Platform (SAP BTP). When combined with SAP Business Application Studio (BAS), CAP enables developers to rapidly build, test, and deploy cloud-native applications.
This article guides you step-by-step on how to build your first CAP application in BAS, from project setup to running a basic service.
SAP CAP provides a set of tools, libraries, and best practices for developing business applications. It uses a domain-specific language called Core Data Services (CDS) for defining data models and services, allowing developers to focus on business logic rather than infrastructure details.
CAP supports both Node.js and Java runtimes, and integrates seamlessly with SAP databases like SAP HANA.
SAP BAS is a cloud-based IDE tailored for SAP development. It provides pre-configured environments, tools, and templates to accelerate CAP development with features such as:
Open a terminal inside BAS.
Use the following command to create a new CAP project scaffold:
npm init @sap/cds
Follow the prompts to provide project name and select Node.js runtime.
Inside your project folder, navigate to the db directory and open schema.cds (create if it doesn’t exist).
Define a simple entity, for example:
namespace my.bookshop;
entity Books {
key ID : UUID;
title : String;
author : String;
}
In the srv folder, create or edit cat-service.cds to expose the Books entity as a service:
using my.bookshop as my from '../db/schema';
service CatalogService {
entity Books as projection on my.Books;
}
cat-service.js file in the srv folder.In the terminal, install dependencies:
npm install
Start the application:
cds watch
The app will start, and BAS will display the service endpoints.
Open a browser and navigate to:
http://localhost:4004/catalog/Books
Initially, it will return an empty array. You can use tools like Postman or REST clients inside BAS to POST data to the service.
Building your first CAP application in SAP Business Application Studio is straightforward and efficient thanks to BAS’s rich development environment and CAP’s simplified programming model. This combination allows SAP developers to focus on delivering business value while leveraging SAP’s cloud infrastructure.
Mastering CAP and BAS is a significant step towards becoming proficient in SAP’s next-generation cloud application development.