Skip to Content
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

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

#EnhanceLearning

Thank you!! 🙂

BR//Dhanasupriya Sidagam

5 Comments
You must be Logged on to comment or reply to a post.
  • 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

     

     

     

  • 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