Skip to Content
Technical Articles
Author's profile photo Dhanasupriya Sidagam

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

In the new URL opened, add first(to=”) at the end and check the output.

#EnhanceLearning

Thank you!! 🙂

BR//Dhanasupriya Sidagam

Assigned Tags

      9 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Nagandla Raghu Ram
      Nagandla Raghu Ram

      Hi Dhanusupriya,

       

      the code in firstcds.cds

      service firstcds {
          function first (to:String) returns String;
      }
      ===========
      the code in firstcds.js
      module.exports = (firstcds) => {
          firstcds.on('first', req => 'Learning')
      }
      This code will always be the same or we can change?
      Thanks and Regards,
      Raghuram

       

       

       

      Author's profile photo Dhanasupriya Sidagam
      Dhanasupriya Sidagam
      Blog Post Author

      We can change and it depends on the requirement.

      Author's profile photo Sarayu Shree
      Sarayu Shree

      Could you please elaborate more on .js and .cds files?

      Thank you .

      Author's profile photo Mike Zhang
      Mike Zhang

      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

      Author's profile photo Jitendra Jhariya
      Jitendra Jhariya

      Hi Dhanupriya,

       

      Can you please answer what Mike had asked as, our requirement is also same.

       

      Thx

      Author's profile photo Emanuele Corso
      Emanuele Corso

      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

      Author's profile photo Sabarna Chatterjee
      Sabarna Chatterjee

      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..

       

      Author's profile photo Gokulakumar Kamalanathan
      Gokulakumar Kamalanathan

       

      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.

      Author's profile photo Shivam Kaushik
      Shivam Kaushik

      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.