🎓beginner⏱25 min.SAP Business Application StudioBeginnerSAP Cloud Application Programming Model
You will learn
โHow to create a CAP project
โHow to develop business applications based on the SAP Cloud Programming Model (CAP)
โHow to run and test your application using the Run Configurations tool The application you’ll develop is a simple bookshop app consisting of a data model with three entities:
โBooks
โAuthors
โGenres The data model is exposed via the Catalog Service. The application has some initial data that is used for testing the application, and some custom logic that runs after reading the books from the Books entity. Once you have all the code in place, you will test the application locally.
To learn more about working with event handlers, see Event Handlers.
Save your changes.
Your application should look similar to the structure shown in the picture below.
Project structure
You can also see the semantic structure of the application in the Project Overview.
Project structure
Step 6Test the app with local database
+
You can explicitly deploy your application to a persistent local SQLite database, or you can run your application and it will implicitly use an in-memory database.
This step describes how to run the application with an in-memory database.
You will first add all required dependencies, and then create and run a run configuration.
Add and install all required dependencies.
From the Terminal menu, select New Terminal.
On the bookshop folder, run the following:
NPM
npm install
From the Activity pane, open the Run Configurations view.
Open Run Configurations view
Click + at the top of the view to add a new configuration.
Open Run Configurations view
Select Bookshop - (CAP Java) as the runnable application from the command palette prompt.
Open Run Configurations view
There might be other run configuration options available in the command palette.
Press Enter to use the default name for the configuration. A new configuration is added to the run configuration tree.
In the Configuration editor, select the Default Profile radio button for the database type.
Open Run Configurations view
Click the green arrow on the right of the configuration name to run the application.
Run
If prompted, open the application in a new tab.
Run
The application opens in the browser.
Click on Books to see the metadata and entities for the service.
Open Run Configurations view
You can also debug your application to check your code logic. For example, to debug the custom logic for this application, perform the following steps:
Place a breakpoint in the function in the service.js file.
In the running app, click the Books entity. It should stop at the breakpoint.
Breakpoint
Click Continue in the debugger until all the books are read and the page is presented.

Remove the breakpoint.
Stop the application by clicking Stop in the Debugger. The number beside the Debug icon represents the number of running processes. Click Stop until there are no processes running.
You have an SAP HANA service (SAP HANA as a Service or SAP HANA Cloud) available in your space.
To create a new instance in your trial account:
Go to your space in the SAP BTP cockpit.
Go to Service Marketplace.
Select SAP HANA Schemas & HDI Containers.
Click Create. Create instance
From the Plan dropdown menu, select hdi-shared as the service plan and provide a name for the new instance.
Click Create.
From the Activity pane, open the Run Configurations view.
Open Run Configurations view
Click + at the top of the view to add a new configuration.
Open Run Configurations view
Select Bookshop - (CAP Java) as the runnable application from the command palette prompt.
Open Run Configurations view
There might be other run configuration options available in the command palette.
Press Enter to use the default name for the configuration. A new configuration is added to the run configuration tree.
In the Configuration editor, select the SAP HANA Cloud radio button for the database type.
Open Run Configurations view
Log in to Cloud Foundry.
From the SAP Cloud Instance dropdown list, select the relevant instance.
From the Deploy the data model before running dropdown list, select the Deploy (with data) radio button.
Open Run Configurations view
Click the green arrow on the right of the run configuration.
Open Run Configurations view
If prompted, open the application in a new tab.
Run
The application opens in the browser.
From the terminal on the bookshop folder, run cds add mta. This adds an mta.yaml file to the root of your application.
Note: If you are working on a trial account, open the mta.yaml file, and in the resources section change the service parameter to hana. Save your changes.
Right-click the mta.yaml file and choose Build MTA Project.
Build MTA
A new folder for mta_archives is created containing the new mtar file.
Right-click the mtar file and choose Deploy MTA Archive.
Deploy MTA
Once the task is complete, your application should be available in your Cloud Foundry space.
To access your application, go to your space in the SAP Cloud Platform cockpit and select Applications from the side menu.
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 7
1. Create new CAP Java project2. Define bookshop data schema3. Define the bookshop service4. Add sample data5. Create a Java class for the custom event handler6. Test the app with local database7. Deploying your app
Joule
AI Notice
Joule is an AI assistant. Generative AI may produce inaccurate, incomplete, or biased information. Always verify important details before acting on them.
Conversations are sent to SAP-hosted large language models for processing. Do not include personal data, credentials, or confidential information in your messages.
Joule's responses are based on the SAP tutorial catalog and may not reflect the latest product changes. For authoritative guidance, consult the linked tutorials and official SAP documentation.