SAP BTP CAPM Application Development and Deployment – Part 2

3 weeks ago 27

In Part 2 of our SAP BTP CAPM (Cloud Application Programming Model) series, we move from theory to practice by building a fully functional CAPM application and integrating its services into a UI5 freestyle basic application.
This guide is designed for beginners who want to understand the CAPM development workflow in SAP Business Application Studio (BAS) from setting up the development space, creating database entities, and exposing them as services, to consuming these services in a UI5 application with basic Create, Read, Update, and Delete (CRUD) operations.

By following this step-by-step walkthrough, you’ll gain hands-on experience in:

  • Setting up a Full-Stack Cloud Application Dev Space in BAS with required SAP extensions
  • Creating a CAPM project with database models and service definitions
  • Loading sample data into your application
  • Building and previewing the application in Fiori Preview
  • Developing a custom UI5 freestyle app to consume CAPM services
  • Implementing Create and Delete operations directly from the UI

This part serves as the practical foundation for future installments, where we’ll connect CAPM to SAP HANA Cloud DB and explore low-code/no-code development in BAS.

NEW INSTRUCTOR LED LIVE TRAINING ANNOUNCEMENT

Course Break up – A to Z of SAP CPI with BTP Integration Suite
Enrollment Link – A to Z of SAP CPI with BTP Integration Suite


Before we proceed with our tutorial, we would like to give you an opportunity to join our ZAPYard’s learning community where we have more than 35 groups and more than 1850 real SAP Consultants interacting with each other daily. Only SAP topics and not BS. Else, they will be banned from the community without warning. 👇👇👇👇

If you want to be part of ZAPYard’s Discussion Community, please feel free to check the below Link. We Ask, Answer, Help and Learn Together. There are more than 35 groups from different topics like Generative AI, SAP Joule, CAPM, BTP, RAP, BPT, Fiori, iRPA, CAI, CPI, PI/PO, ABAP on HANA, SAPUI5, SAP Build, SAP Adobe Forms, ChatBots, SAC etc. Join any group of your interest and interact with our Community.

Join ZAPYard’s WhatsApp Community – Ask, Answer, Propose & Defend SAP Topics

Lets start with creating a basic CAPM application for a beginner and use the CAPM service in a UI5 freestyle basic application

Perquisites:

  1. You have a BTP Trial account created.
  2. You have subscribed to SAP Business Application Studio

Step 1: Setting Up Project in Development Space on BAS for CAPM Full Stack UI5 Development

Open the Business Application Studio from your SAP BTP Trial account.

Create a new Dev Space, make sure you select Full-Stack Cloud Application and check the additional SAP Extensions:

  1. SAP HANA Calculation View Editor
  2. SAP HANA Performance Tools
  3. SAP HANA Tools
  4. SAP HANA XS Advanced Tools
  5. SAP HANA Smart Data Integration Tools

The Dev Space is always in stopped space; you can think of it as a Virtual Machine. When it’s not in use it automatically stops & you will have to start the same to get going. Click on the play to start your Development Space

It will go to the running phase again.

Finally, it opened, you can bookmark this as well to directly access your Specific Development Space.

Now let’s navigate to Project Work Space. Click on file & choose Open Workspace from the drop-down list.

You will get the below screen. Choose projects & click open.

Now we are in the project workspace. Let’s open a terminal and proceed further. Click on Terminal & choose New Terminal.

You will get the below terminal screen. Now copy the below command & run it in your terminal. This will create a Project with the name: cap_tutorial.
You can put the command like: mkdir cap_tutorial

You will see that a new project folder is created with the name cap_tutorial. You the below command to navigate to this new folder in the terminal.

cd cap_tutorial

You will be switched to the created project folder cap_tutorial. Copy the below command to create the CAPM project.

cds init

The creation will start in our project folder & let’s wait for the build.

Cool, now you have your project ready. The structure should be like the below screen.

As you can see, we have 3 major folders

  • db
  • srv
  • app

Here the db is the database where you can define any data models, and the data model will be exposed as a service in the srv folder and then the service can be consumed in the application generated in the app folder.

Step 2: Creating Database Entities for CAPM

Let’s start with the DB Folder: It contains the Database Entity which is based on CDS Model. The design-time artefacts declared in this file will be converted to run-time, physical artefacts in the database. In this example, the entities will become tables.
Right Click on db folder & create a New File.

Name the file as data-model.cds

data-model.cds


Now, let’s create an entity, you can copy the below code and paste it into the created file.

Step 3: Creating a Service for CAPM using the Data-Model

Now go to the srv folder. We will be declaring services to expose the database entities we declared in the previous step.
Create a new file in srv folder by right-clicking on the same.

Name the file as cat-service.cds

cat-service.cds

Copy & Paste the below code in the created file.

Let’s build the project now once. For that do cds build

cds build

Now, let’s finally see what we have built. Let’s do cds watch it will run your project built till now.

cds watch

You will a server is running with a localhost port 4004, and you have click on Open in a New Tab

You can click the $metadata to find the all the fields and the entity set.

Now click on the Products Service, you will see it loaded with no values.

So, you got an idea how to create a very simple data model and expose that into a service.
Now let’s a new data-model and do the same steps again for a Sales Order Scenario.

Step 4: Adding a new Entity in the CAPM application Data-Model

Go to the cat-service.cds file add the below code.

Step 5: Modify the Service file with the new data-model

Now ae we added a new entity in the data model, we have to modify the service file as well.
The whole service file looks like the below:

Now, let’s do again cds build and then cds watch.

You can see the both the end points are available. Similarly, you can test the metadata and the service.

Step 6: Create sample date to load in the service.

So, let’s create a folder in db folder. Right-click on db folder and select New Folder

Name your folder as data.

Now create a new file in the created data folder.

Name your file as cap_tutorial-SalesOrders.csv. Here cap_tutorial is

the namespace – SalesOrders is our entity. It’s a nomenclature that needs to be followed for mapping the data.

cap_tutorial-SalesOrders.csv

Now, it’s time to create actual data. So, in CAPM we use .csv files to create local data. You can easily create them in Excel or Libre or even in Notepad. For now, you can copy-paste it from below.

Your final Project Structure should look something like this:

First let’s save everything and then we will proceed.

We will have to do a cds build.

Now let’s do cds watch, this time when we navigate to the Entity SalesOrders.

We will be able to see the added data.

Now you can click on Fiori preview.

You will see the below screen, with No Data. No need to worry, just click on Setting Icon.

Choose all the columns for which you want to see the data and click OK.

We can see the Data is populated now in our fiori preview.

Fiori Preview is a fully you can get a feel of the final Integration here. Like we can also use the Filter Feature.

In this part of our SAP BTP CAPM series, we walked through the process of setting up a full-stack CAPM project in SAP Business Application Studio, defining database entities, and exposing them as services. You now have a working backend with sample data that can be accessed and tested in Fiori Preview—a solid foundation for building real-world applications.

But a backend service alone isn’t enough—applications become truly powerful when their data is accessible and manageable through a user-friendly interface.

📢 Coming up next in Part 3– We’ll take this CAPM service you just built and integrate it into a UI5 freestyle application. You’ll learn how to connect to your CAPM service, display live data in a table, and implement Create and Delete operations directly from the UI. This will bring your application to life and set the stage for more advanced features in the later parts of the series.

If you found this guide useful, share your thoughts, challenges, or success stories in the comments. Your feedback helps us create more targeted and valuable content for your ABAP on Cloud and CAPM learning journey.

Please note: This CAPM Series is the learning material from our ZAPcademy.com Instructor Led Live Online Training on the topic SAP BTP CAPM – Basic to Advanced. You may avail the recordings, notes and assignments of this training from here.

Please follow our LinkedIn PageLinkedIn Group , Facebook PageFacebook GroupTwitter & Instagram.

Do not forget to SUBSCRIBE to our YouTube Channel for Free Courses and Unconventional Interesting Videos.

Do join ZAPYard’s Learning Community.

A to Z of SAP BTP CAPM Learning Series

Read Entire Article