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

Reuse a CAP Java Service

Create a new application and reuse the existing CAP Java service.

Overview

🎓 beginner 20 min. SAP Cloud Application Programming ModelBeginnerSAP Business Technology PlatformJava

You will learn

  • How to reuse a CAP project through NPM packages
  • How to load sample data using CSV files
  • How to use the localized keyword
René Jeglinsky R René Jeglinsky December 10, 2024
Created by December 10, 2024
Contributors

Prerequisites

Steps

Intro

Now, that your products service is ready to be reused, you will build a bookstore application upon it.

In this tutorial you will create the model and the services of the bookstore application. After that you will initialize the database of your bookstore application with localized example data coming from CSV files.

You will then run your application – still without any custom coding required – and see the localization features of CAP in action.


Step 1 Create bookstore project skeleton

From the products service that you created in the previous tutorial, we just want to reuse the domain and service models. For the bookstore, which you will develop in this tutorial, we need to create and initialize a bookstore project first.

Make sure you stopped your application from the previous tutorial.

  1. From the main menu of SAP Business Application Studio, choose Terminal New Terminal.

  2. Before adding the bookstore project, we need to make sure that you are in the projects folder. Both projects (products-service and bookstore) should be placed next to each other. Run the following command in the newly created terminal to go back to the projects folder:

    Shell/Bash
    cd ~/projects
  3. Now that you are in the correct folder, run the following command:

    Shell/Bash
    cds init bookstore --add java
  4. To open the bookstore project in a new workspace go to File Open Folder.

  5. Choose bookstore from the project list and then OK.

    open the bookstore application
    open the bookstore application

    If you see a notification asking if you want to synchronize the Java classpath/configuration, choose Always.

    If you have any problem indication for any of the pom.xml files yet, don’t worry and ignore them for now.

Step 2 Install reusable service as npm dependency
+
Step 3 Define bookstore domain model
+
Step 4 Define bookstore service
+
Step 5 Load sample data using CSV files
+
Step 6 Run and test the bookstore application
+

Resources

Discussion

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

Submit detailed feedback Discuss in Community
Steps
Step 1 of 6
1. Create bookstore project skeleton 2. Install reusable service as npm dependency 3. Define bookstore domain model 4. Define bookstore service 5. Load sample data using CSV files 6. Run and test the bookstore application

Learn more →