Besides developing directly in the Cloud using SAP Business Application Studio it is also possible to use the SAP Cloud Application Programming Model (CAP) on your local environment.

Install Node.js

Head over to the official node.js download page and get the latest LTS (long time support) version. This download usually comes with npm.

After Node.js is installed, open a new Terminal to check if the installation was successful by checking the installed Node.js version

% node -v
v14.15.1

In my case, I have version 14.15.1 installed.

Install Visual Studio Code (VSCode)

Download and install the latest stable build for your OS from the Visual Studio Code website.

Install VSCode SAP CDS Extension

Once done start VSCode and open up the Extensions view. Search for cds and click on the provided extension by SAP SE. Press the blue Install button to add this extension.

Install code Shell command

Open the Command Palette (⇧⌘P) and type ‘shell command’ to press the Shell Command: Install 'code' command in PATH command to install it.

Install VSCode Shell Command

This enables us to run VSCode directly from our Terminal.

Install the cds development kit

Open a new terminal window and execute the following command to install the cds development kit globally:

npm i -g @sap/cds-dk

Verify the successful installation by running command cds without arguments.

% cds

USAGE

    cds <command> [<args>]
    cds <src>  =  cds compile <src>
    cds        =  cds help

COMMANDS

    i | init       jump-start cds-based projects
    a | add        add a feature to an existing project
...

Create a new project

To initiate a new project execute the below command to create a new project called my-new-project in the current directory.

cds init my-new-project

Navigate into the newly generated folder my-new-project and run npm install to install all required dependencies.

% cd my-new-project 
% npm install

Define a new model

Create a new file cat.cds with content

service cat {
  function meow() returns String;
}

Create a new file cat.js with content

module.exports = (cat) => {
  cat.on('meow', req => `meeeoooowwww!`)
}

Serve service locally

Execute command cds serve cat.cds to run the newly created service.

% cds serve cat.cds

[cds] - model loaded from 1 file(s):

  cat.cds

[cds] - model loaded from 1 file(s):

  cat.cds

[cds] - serving cat { at: '/cat', impl: 'cat.js' }

[cds] - launched in: 273.87ms
[cds] - server listening on { url: 'http://localhost:4004' }
[ terminate with ^C ]

Navigate to localhost:4004 in your browser to get further information about the service, like automatically generated metadata.

SAP CAP Service running locally

You can call the created function by navigating to localhost:4004/cat/meow()

SAP CAP result of function call