Learn to Create and Use SAP® CAPM Apps with SAP® BAS!
Hey there, SAP® Tech Masterminds! We’re thrilled to bring you a fun and easy two-part blog series. We’ll guide you through creating and using SAP® CAPM Services in SAP® BAS for your SAP® Fiori® Element Apps.
Whether you’re new to coding or a seasoned expert, these blogs are for you. Let’s get started!
Now that you’ve built your SAP® CAPM app, it’s time to put it to work. In the second part of our series, we’ll show you how to:
Connect your CAPM services to SAP® Fiori® Elements apps.
Turn your services into awesome, user-friendly apps using SAP® Fiori® Elements.
Follow simple, clear instructions to make everything work smoothly.
So grab your favorite snack, get comfy, and join us on this coding adventure. Stay tuned for the first part – it’s going to be amazing!
Also, to Learn Fiori® Elements using SAP® CAPM and SAP® RAP you can enroll in the course Learn SAP® Fiori® Elements where we will learn in a Step-by-Step Fashion the development of Apps Using Fiori® Elements.
For the best offers on the course check the Offer Page.
The final result will look similar to the screenshot below in the Navigation Details Screen. Based on the Nesting of Navigation the Final Result will differ.
Good practice is:
1. Not do the nesting more than 3 levels.
2. Not referencing more than 1 Reference Facets per collection or you will face rendering issues.
1. Create a SAP® CAPM Project to generate sample files and structure. In the BAS CLI you can write:
cds init sample-project
Some of the files created in the project like the data CSV file and the app folder will be added in the coming steps:
2. Go to the db folder and create a file data-models.cds to add the schema:
namespace sampleProject;
entity Products {
key ID: UUID;
productName: String;
category : String;
price : Decimal;
description : String; // New field for product description
image : String; // New field for image URL
}
3. Add sample data values inside the data folder in a CSV file and name it project-Products.csv:
ID;productName;category;price;description;image
"e3b0c442-98fc-1c14-9fb0-c4e9b3c77c63";"Laptop";"Electronics";999.99;"High-performance laptop for professionals";"https://i.ibb.co/WWfNSgp/openui5.png"
"fe3a9ec0-93d6-2f3b-ad7c-c8f330b7606c";"Smartphone";"Electronics";599.99;"Latest model with advanced features";"https://i.ibb.co/WWfNSgp/openui5.png"
"b4e9b3c7-7c63-4e3b-0c44-29fc1c149fb0";"Coffee Maker";"Home Appliances";49.99;"Brews perfect coffee every time";"https://i.ibb.co/WWfNSgp/openui5.png"
4. Create a basic service inside the srv folder in the file catalog-service.cds :
using sampleProject from '../db/data-model';
service CatalogService {
entity Products as projection on sampleProject.Products;
}
5. We have created a SAP® CAPM App to explore which can be used in a Fiori® Element Template, so let’s start making that. Note, that this SAP® CAPM App will be used in the Fiori® Element Template, so we need to keep the App running and create a new Project From Template which we will do next.
To run the App we can use the Start Script of the App from the package.json file:
Choose a Service:Choose a service from the SAP® BTP marketplace that you want to bind to your application.For example a Database(DB) service like PostgreSQL.
Create a Service Instance:Create a service instance of the chosen service in your SAP® BTP space. With CF CLI we can use the command
Bind the Service:Bind the service Instance to your Application, by using the Cloud Foundry CLI or the SAP® BTP cockpit to bind the service instance manually. Also, service-binding can be done by passing service information with the Manifest.YML file.
VCAP Variable:VCAP is an environment variable in a JSON data format that is provided to an Application when it is hosted in Cloud Foundry (SAP® BTP), this variable act as a way to share the information that the application needs to connect to the service instance.
Use the ServiceOnce the Service is Bound you will get the required credentials to connect to the service via VCAP environment variable. After the connection to the service, you can use the service instance. Based on the service if it is a Database, server, messaging queue, etc. the operation related to connecting and usage will be different, which needs to be handled accordingly in the application.
Prepare your Application: Make sure your application is ready to be deployed and meets the requirements for deployment to SAP® BTP.
Connect to SAP® BTP: Connect to the SAP® BTP environment using a Cloud Foundry CLI or a Web-based interface.Login to CF CLI Using:
cf login -a [API-END] -o [ORG] -s [Space]
After that, one needs to enter the prompt password in CLI.
Choose a Deployment Method: Decide on a deployment method using the Cloud Foundry CLI or a web-based interface such as the SAP® BTP cockpit. Application Buildpack needs to be also checked if the runtime environment that the Application needs is present. To check available buildpacks use command:
cf buildpack
Create a Deployment Descriptor: Create a deployment descriptor, such as a manifest(YAML or YML) file, that specifies the configuration for your application.
Deploy and Monitor App: Use below CLI command below to Push the Application to SAP® BTP