---
title: How to Build an SAP Cloud Application Programming Model Application
description: Get a crash course in developing an application using the SAP Cloud Application Programming Model in VS Code.
image: https://blog.sap-press.com/hubfs/How%20to%20Build%20an%20SAP%20Cloud%20Application%20Programming%20Model%20Application.png
---

[![rheinwerk-sappress-logo-header-1](https://blog.sap-press.com/hubfs/rheinwerk-sappress-logo-header-1.svg)](https://blog.sap-press.com/) [Blog](https://blog.sap-press.com)

- Books 
    - Get an overview of our books and courses on every relevant SAP topic. 
          - [Programming](https://sap-press.com/programming/)
          - [Administration](https://sap-press.com/administration/)
          - [BI](https://sap-press.com/business-intelligence/)
          - [Finance](https://sap-press.com/finance-controlling/)
          - [Logistics](https://sap-press.com/logistics/)
          - [HR](https://sap-press.com/human-resources/)
          - [CRM & Sales](https://sap-press.com/marketing-sales/)
          - [HANA](https://sap-press.com/hana/)
          - [Introductions](https://sap-press.com/introductions/)
          - [E-Bites](https://sap-press.com/e-bites/)
          - [Certification Guides](https://www.sap-press.com/certification-guides/)
          - [Rheinwerk Courses](https://www.sap-press.com/online-courses/)
- Book Subscription 
    - Get unlimited access to all SAP PRESS books! 
          - [SAP PRESS Subscription](https://sap-press.com/subscriptions/)

[Programming](https://blog.sap-press.com/tag/programming)

# How to Build an SAP Cloud Application Programming Model Application

![SAP PRESS](https://blog.sap-press.com/hubfs/Twitter_profile_pic.svg)  by [SAP PRESS](https://blog.sap-press.com/author/sap-press)

In this blog post, we’ll produce a simple SAP Cloud Application Programming Model application to familiarize you with the CDS server and SAP Cloud Application Programming Model.

 

## Creating a Project

You can create an [SAP Cloud Application Programming Model](https://blog.sap-press.com/introducing-the-sap-cloud-application-programming-model-cap) project by running the command cds init \<folder name\>, which will create a project in the specified folder name. Once the project is created, you’ll be prompted with links to both the SAP samples and documentation for SAP Cloud Application Programming Model, as shown in this figure.

 

![SAP Cloud Application Programming Model: Project Initialization](https://blog.sap-press.com/hs-fs/hubfs/2336_07_010.png?width=671&height=468&name=2336_07_010.png)

 

## Running a Project

Now that the project is set up, you’ll need to install the dependencies and start the local server. To install dependencies, simply navigate to the project folder and run [npm](https://learning.rheinwerk-computing.com/javascript#npm)install. Once the install has completed, start the CDS server by running the command cds watch, as shown here.

![CDS Server Started](https://blog.sap-press.com/hs-fs/hubfs/2336_07_011.png?width=719&height=562&name=2336_07_011.png)

 

**Using SQLite for Development:** Running the cds watch command bootstraps an SQLite in-memory database by default, which is what powers your development environment.

 

You’ll see that the live reload feature is enabled: Every time you save a file, the running version of your server will be refreshed to share the updated resource. Notice also that no models are found, *yet*.

 

**Accessing Your Local SAP Cloud Application Programming Model Server:** Notice in the terminal that it tells you the URL for your local server. By default, the local server will map to *localhost:4004*. Accessing this URL with no parameters or paths will provide an overview of connected available applications and services, but right now, this list will be empty, as shown below.

 

![CDS Server Status Page](https://blog.sap-press.com/hs-fs/hubfs/2336_07_012.png?width=454&height=378&name=2336_07_012.png)

## Defining a Service

We’ll now create a simple *hello world* app by defining a service, implementing the service, and consuming the service.

 

**Fundamental Types for CDS Definitions:** You should be familiar with several core types before beginning CDS development, such as the following: 

- **Entity:** An entity is a distinct object containing a set number of CDS elements. You can also refer to an entity as a table or a design-time file.
- **Element:** An element is a property, specifically a property in relation to an entity. An element can be a simple key and type, or you can apply element modifiers to specify that it is a key or a default value.
- **Type:** A descriptor of the CDS element describing the primitive type (e.g., string or integer). 

The following code defines an example entity:

 

`entity Car : {`

`   brand : String;`

`   model : String;`

`   buildDate : Date;`

`   color : String;`

`   weight : Integer;`

`}`

 

The entity is a car with five data elements/properties. Each of these properties has an assigned type, such as string, integer, or date.

 

To start, let’s create a CDS entity (also known as a “service”) that contains a function. Create a new file within the *srv* folder called *world.cds* and add the following code:

 

`service say @{`

`   function hello (to:String) returns String;`

`}`

 

Save the file. Note that the terminal has now registered the service **say**, as shown in this figure.

 

![Defining a CDS Service](https://blog.sap-press.com/hs-fs/hubfs/2336_07_013.png?width=720&height=543&name=2336_07_013.png)

 

Now, let’s implement this service.

**7**

## Implementing a Service

Implementing the service using [Node.js](https://learning.rheinwerk-computing.com/javascript#nodejs) is quite simple and can be done in two styles: using Express.js handlers or using [JavaScript](https://learning.rheinwerk-computing.com/javascript) ES6 classes. We recommend the Express-style handlers option because JavaScript ES6 classes are less flexible (you can only register one handler per event). This decision isn’t a problem for the purposes of this tutorial but can cause problems in your initial build/development phase.

 

To implement the service, you must create a JavaScript file to match your service definition. Create this new file under the *srv* folder, name the file *world.js*, and add the following code:

 

`module.exports = (say) => {`

`   say.on ("hello", req => `Hello ${req.data.to}!`);`

`}`

 

Save the file and note that the terminal has now registered the implementation of our service, as shown here.

![Implementing a CDS Service](https://blog.sap-press.com/hs-fs/hubfs/2336_07_014.png?width=720&height=493&name=2336_07_014.png)

 

Now, we can consume our service.

 

## Consuming a Service

Consuming the service requires your local server to be running (as described earlier). In our example, in the terminal, the service path is *say*, the function within this service is *hello*, and this function takes the parameter *to*.

 

In the style of an Express server, you can consume this service via the URL *http://localhost:4004/say/hello(to='readers')*, as shown in this figure.

![Consuming a CDS Service in a Browser](https://blog.sap-press.com/hs-fs/hubfs/2336_07_015.png?width=857&height=182&name=2336_07_015.png)

 

If you’ve worked with Express servers before, this section will all be familiar and intuitive. If you haven’t, you should get used to this interface quite quickly. Consuming SAP Cloud Application Programming Model services is as straightforward as piecing together your service definition and implementation.

 

The complete code repository for this section is found on GitHub at *[http://s-prs.co/v560617](http://s-prs.co/v560617)*.

[Explore 11 Joule commands for CAP programming here.](https://blog.sap-press.com/11-key-joule-commands-for-development-with-sap-cap)

 

## Learn CAP with Rheinwerk Courses!

Build cloud-native applications on SAP BTP with our CAP-focused online courses. They cover everything from CDS domain modeling and Node.js service logic to SAP Fiori elements UIs, deployment to Cloud Foundry, and AI-assisted development. Each one is instructor-led (live and on-demand), includes recordings and slide decks, and gives you practical skills you can use in your own SAP projects right away. Click on the banner below to get started!

 

[![blog\_courses\_cap\_series](https://blog.sap-press.com/hs-fs/hubfs/blog_courses_cap_series.png?width=600&height=200&name=blog_courses_cap_series.png)](https://www.sap-press.com/online-courses/topics/programming/)

 

*Editor’s note*: This post has been adapted from a section of the book *[Visual Studio Code for SAP](https://www.sap-press.com/visual-studio-code-for-sap_5605/?utm_source=sappressblog&utm_medium=referral&utm_campaign=Blogs&utm_term=2336_chapter7&utm_content=2336)* by Leon Hassan.

## Recommendation

[![Visual Studio Code for SAP](https://blog.sap-press.com/hs-fs/hubfs/social-suggested-images/2336-Dec-07-2022-12-55-49-2788-PM-1.jpg?width=170&name=2336-Dec-07-2022-12-55-49-2788-PM-1.jpg)](https://www.sap-press.com/visual-studio-code-for-sap_5605/?utm_source=sappressblog&utm_medium=referral&utm_campaign=Blogs&utm_term=2336_chapter7&utm_content=2336)

**Visual Studio Code for SAP**

Start programming your SAP applications in Visual Studio Code! This hands-on guide begins with an overview of how VS Code works and how it connects to your SAP systems. Then learn how to manage version control by integrating VS Code with Git. Follow step-by-step instructions to develop SAPUI5 web components, build applications with ABAP, create SAP Fiori apps using SAP Fiori elements, and work with the SAP Cloud Application Programming Model. Get everything you need to master this IDE!

[Learn More](https://www.sap-press.com/visual-studio-code-for-sap_5605/?utm_source=sappressblog&utm_medium=referral&utm_campaign=Blogs&utm_term=2336_chapter7&utm_content=2336)

![SAP PRESS](https://blog.sap-press.com/hubfs/Twitter_profile_pic.svg)

**by [SAP PRESS](https://blog.sap-press.com/author/sap-press)**

SAP PRESS is the world's leading SAP publisher, with books on ABAP, SAP S/4HANA, SAP IBP, intelligent technologies, SAP Business Technology Platform, and more!

[Programming](https://blog.sap-press.com/tag/programming)

[![Share on facebook](https://7528309.fs1.hubspotusercontent-na1.net/hub/7528309/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/facebook-color.png?width=24&name=facebook-color.png)](https://www.facebook.com/share.php?u=https%3A%2F%2Fblog.sap-press.com%2Fhow-to-build-an-sap-cloud-application-programming-model-application%3Futm_medium%3Dsocial%26utm_source%3Dfacebook) [![Share on linkedin](https://7528302.fs1.hubspotusercontent-na1.net/hub/7528302/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/linkedin-color.png?width=24&name=linkedin-color.png)](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fblog.sap-press.com%2Fhow-to-build-an-sap-cloud-application-programming-model-application%3Futm_medium%3Dsocial%26utm_source%3Dlinkedin) [![Share on twitter](https://7528304.fs1.hubspotusercontent-na1.net/hub/7528304/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/twitter-color.png?width=24&name=twitter-color.png)](https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Fblog.sap-press.com%2Fhow-to-build-an-sap-cloud-application-programming-model-application%3Futm_medium%3Dsocial%26utm_source%3Dtwitter&url=https%3A%2F%2Fblog.sap-press.com%2Fhow-to-build-an-sap-cloud-application-programming-model-application%3Futm_medium%3Dsocial%26utm_source%3Dtwitter&source=tweetbutton&text=) [![Share on email](https://7528311.fs1.hubspotusercontent-na1.net/hub/7528311/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/email-color.png?width=24&name=email-color.png)](mailto:?subject=Check+out+https%3A%2F%2Fblog.sap-press.com%2Fhow-to-build-an-sap-cloud-application-programming-model-application%3Futm_medium%3Dsocial%26utm_source%3Demail&body=Check+out+https%3A%2F%2Fblog.sap-press.com%2Fhow-to-build-an-sap-cloud-application-programming-model-application%3Futm_medium%3Dsocial%26utm_source%3Demail)

### Comments

### Latest Blog Posts

[![How to Develop an SAP Fiori App on SAP Business Application Studio](https://blog.sap-press.com/hs-fs/hubfs/Developing%20SAP%20Fiori%20Apps%20on%20SAP%20Business%20Application%20Studio.png?height=600&name=Developing%20SAP%20Fiori%20Apps%20on%20SAP%20Business%20Application%20Studio.png)](https://blog.sap-press.com/how-to-develop-an-sap-fiori-app-on-sap-business-application-studio)

[Programming](https://blog.sap-press.com/tag/programming)

## [How to Develop an SAP Fiori App on SAP Business Application Studio](https://blog.sap-press.com/how-to-develop-an-sap-fiori-app-on-sap-business-application-studio)

[Read More](https://blog.sap-press.com/how-to-develop-an-sap-fiori-app-on-sap-business-application-studio)

[![3 Ways SAP Build Streamlines Application Development](https://blog.sap-press.com/hs-fs/hubfs/3%20Ways%20SAP%20Build%20Streamlines%20Application%20Development.png?height=600&name=3%20Ways%20SAP%20Build%20Streamlines%20Application%20Development.png)](https://blog.sap-press.com/3-ways-sap-build-streamlines-application-development)

[Programming](https://blog.sap-press.com/tag/programming)

## [3 Ways SAP Build Streamlines Application Development](https://blog.sap-press.com/3-ways-sap-build-streamlines-application-development)

[Read More](https://blog.sap-press.com/3-ways-sap-build-streamlines-application-development)

**Subscribe to our blog!**Get notified about future blog updates.

- <https://www.facebook.com/sappress>
- <https://twitter.com/sappress>
- <https://linkedin.com/company/sap-press>
- <https://www.instagram.com/sap_press/>
- <https://blog.sap-press.com/rss.xml>

### The official SAP PRESS Blog

As the world’s leading SAP publisher, SAP PRESS’ goal is to create resources that will help you accelerate your SAP journey. The SAP PRESS Blog is designed to provide helpful, actionable information on a variety of SAP topics, from SAP ERP to SAP S/4HANA. Explore ABAP, FICO, SAP HANA, and more!

### SAP Blog Topics

- [All Topics](https://blog.sap-press.com)
- [Logistics](https://blog.sap-press.com/tag/logistics)
- [Programming](https://blog.sap-press.com/tag/programming)
- [FICO](https://blog.sap-press.com/tag/fico)
- [Administration](https://blog.sap-press.com/tag/administration)
- [Business Intelligence](https://blog.sap-press.com/tag/business-intelligence)
- [Featured](https://blog.sap-press.com/tag/featured)
- [What Is?](https://blog.sap-press.com/tag/what-is)
- [CRM & Sales](https://blog.sap-press.com/tag/crm-sales)
- [Video](https://blog.sap-press.com/tag/video)
- [Human Resources](https://blog.sap-press.com/tag/human-resources)

### Blog curated by

[![Rheinwerk Publishing & SAP PRESS Logo](https://blog.sap-press.com/hubfs/rheinwerk-sappress-logo-header-1.svg)](https://sap-press.com) [Visit the SAP PRESS Store](https://sap-press.com)

### About

- [Home](https://sap-press.com/)
- [About Us](https://sap-press.com/the-publisher/)
- [Contact](mailto:info@rheinwerk-publishing.com)
- [Legal Notes](https://sap-press.com/legal-notes/)
- [Privacy Policy](https://sap-press.com/privacy/)
- [Terms of Use](https://sap-press.com/terms/)
- [Guest Posting](https://blog.sap-press.com/guest-posting)

© 2026 Rheinwerk Publishing, Inc. | Change Privacy Options

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "SAP PRESS",
    "url" : "https://blog.sap-press.com/author/sap-press"
  },
  "dateModified" : "2026-09-23T13:04:25.540Z",
  "datePublished" : "2023-05-17T13:00:00.000Z",
  "headline" : "How to Build an SAP Cloud Application Programming Model Application",
  "image" : [ "https://blog.sap-press.com/hubfs/How%20to%20Build%20an%20SAP%20Cloud%20Application%20Programming%20Model%20Application.png" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog.sap-press.com/how-to-build-an-sap-cloud-application-programming-model-application",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog.sap-press.com/hubfs/Logo-1.jpg"
    },
    "name" : "Rheinwerk Publishing, Inc."
  }
}
```