SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Build a CAP Application

This guide is a step-by-step walkthrough to build a CAP Node.js or Java application.

Overview

🎓 beginner 30 min. SAP Cloud Application Programming ModelBeginnerSapui5JavaNode JsSAP Business Technology PlatformSAP Fiori

You will learn

  • How to create a CAP project.
  • How to add a domain model.
  • How to create services.
  • How to add data to your database.
Created by January 4, 2024
Contributors

Prerequisites

Prerequisites

You’ve configured the SAP Business Application Studio. Follow the steps in the Set Up SAP Business Application Studio for Development tutorial that is part of the Develop a Full-Stack CAP Application Following SAP BTP Developer’s Guide tutorial group.

OUT OF MAINTENANCE

This tutorial is no longer maintained. For an up-to-date version and support with any issues, refer to the Develop a Full-Stack CAP Application Following the SAP BTP Developer’s Guide mission in the SAP Discovery Center.

Steps

Step 1 Create a CAP project

You can create a CAP project in either Node.js or Java. You have to choose one way or the other and follow through. The tabs Node.js and Java provide detailed steps for each alternative way.

  1. In SAP Business Application Studio, go to your IncidentManagement dev space.

    Make sure the IncidentManagement dev space is in status RUNNING.

  2. Choose the burger menu and choose TerminalNew Terminal.

    Terminal
    Terminal

  3. Navigate to the projects folder from the root directory.

    Shell
    cd projects

    Your main interaction is through the cds command. It’s used to build, run, and debug your CAP application. You can also use cds to enrich your application with additional capabilities such as messaging, multitenancy, or cloud integration. You can learn more about the tool’s capabilities in Command Line Interface (CLI).

  4. Create a new project using cds init.

    Shell
    cds init --add nodejs incident-management

    This command creates a folder incident-management with your newly created CAP project.

  5. Choose the Explorer icon and then choose Open Folder. Type /home/user/projects/ in the field and select incident-management. Choose OK to open the project in SAP Business Application Studio.

    Open SAP Business Application Studio folder
    Open SAP Business Application Studio folder

    You can also use the Cmd+Shift+E (macOS) or Ctrl+Shift+E (Windows/Linux) key combination to quickly navigate to the Explorer.

  6. While you’re in the incident-management folder, choose the burger menu and then choose TerminalNew Terminal.

  7. Install dependencies with the following command:

    Shell
    npm install
  8. Start a CAP server:

    Shell
    cds watch

    The CAP server serves all the CAP sources from your project. It also “watches” all the files in your projects and conveniently restarts whenever you save a file. Changes you’ve made are immediately served without you having to run the command again. In this newly created project the CAP server tells you that there are no models or service definitions yet that it can serve.

    Here is the output that you get:

    Shell
    cds serve all --with-mocks --in-memory?
    live reload enabled for browsers
    
    ___________________________
    
    No models found in db/,srv/,app/,schema,services.
    Waiting for some to arrive...
Step 2 Add a domain model
+
Step 3 Create services
+
Step 4 Generate comma-separated values (CSV) templates
+
Step 5 Fill in the initial data
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 5
1. Create a CAP project 2. Add a domain model 3. Create services 4. Generate comma-separated values (CSV) templates 5. Fill in the initial data

Learn more →