Technical Articles
SAP Cloud Application Programming Model – Demo1
Hello All
SAP Cloud Application Programming Model (CAPM) is one of my learning’s during this COVID lockdown. In this blog, we would see framework, components, IDE tools and a quick demo in SAP Cloud Application Business Studio.
Below image is the understanding of SAP Cloud Platform Programming Model:
Components of SAP CAPM
Core Data Services (CDS): It is a data modelling infrastructure used to define data models and service definitions, queries and expressions in object notation.
Service SDK’s: CAPM have libraries available for both Java and Node.js which used to provide and consume services through synchronous and asynchronous API’s. SDK’s also have integration to services such as authentication and credential-flows and on/off boarding of SaaS tenants.
SAP Business Application Studio: IDE to build business applications.
Design Principles of SAP CAPM:
Zero Lock-In: To build UI, we can use SAP Fiori Elements. CAPM can be used with technologies what we want to use.
Non-Intrusive: CAPM is assumption free which is used to code regardless of the choice of architecture/ methodology.
Platform-Agnostic: We can build independent applications from the underlying cloud infrastructure using API approach.
Steps to the demo of SAP CAPM using CDS and Node.js and SAP Cloud Application Studio as IDE.
Enter the SAP Cloud platform trial account.
Click on trial sub account
From the subscriptions, Subscribe to SAP Business Application Studio(Advanced version of SAP WEB IDE Full Stack).
Go to Application and create dev space.
Click on created space: SAPCAPM and below is the home page of SAP Business Application Studio.
Choose Terminal → New Terminal from the header. Go to the projects directory.
Let’s create a project by executing the command cds init firstprog in the terminal. After command execution, we can see the project structure created in workspace with folders for services(srv), database(db) and UI(app)
Create a cds file (firstcds.cds) in srv folder.
//Define a service name and code yours
service firstcds {
function first (to:String) returns String;
}
Create a js file (firstcds.js) with the same name as cds file in srv folder.
//module.exports is an instruction to Node.js to export first function
//below to be exported so that other files can access the first function defined
module.exports = (firstcds) => {
firstcds.on ('first', req => 'Learning')
}
Now write the command cds run to the terminal.
user: firstprog $ cds run
Click on the highlighted button.
open the below link
#EnhanceLearning
Thank you!! 🙂
BR//Dhanasupriya Sidagam
Hi Dhanusupriya,
the code in firstcds.cds
We can change and it depends on the requirement.
Could you please elaborate more on .js and .cds files?
Thank you .
Hi Dhanusupriya,
Is it possible to use Application Studio to develop node.js module which access tables in hdi containers but not using CDS? Our goal is to write custom node.js code to interact with HANA tables and stored procedures, could you please provide an example? Thank you.
Best wishes,
Mike
Hi Dhanupriya,
Can you please answer what Mike had asked as, our requirement is also same.
Thx
Hi Dhanusupriya,
"Let’s create a project by executing the command cds init firstprog in the terminal."
i can't run the cds command:
----------------------------------------------------------------
user: projects $ cds init firstprog
bash: cds: command not found
why?
Emanuele
Same happened for me..
The best solution is to create a new Account and setup your Business studio. If you do that, you will be able to execute the "cds init" code..
While executing the program got this error.
user: projects $ firstprog $ cds run
bash: firstprog: command not found
when i try run the command, it give me this error. Any help to understand why this happened.
Can anybody can suggest that where I learn about SAP CAPM any course or document Because no where I am getting for SAP CAPM basically I want to learn to develop Full Stack cloud application so anyone please help me.