Skip to Content
Technical Articles

Cloud Application Programming Model (CAP) for SAP Cloud Platform – start here

Note: While this blog post was originally published in 2018, it’s been updated for 2020 thanks to great help and input from the excellent Former Member. Take a few mins to have a fresh look through, as you’ll find that many items have been updated. And don’t forget to “share & enjoy“!

There’s been a lot of activity and interest around CAP for SAP Cloud Platform, not least during the last couple of years of SAP TechEd events, and also as it coalesces into a fundamental technology in the cloud development stack. I thought it would be useful to provide an overview of the key resources, for folks who are wondering how to get started.

Briefly, CAP for SAP Cloud Platform is a framework of tools, languages and libraries, some from SAP, some open source. With these tools, languages and libraries you can efficiently and rapidly build enterprise services and applications in a full-stack development approach. It guides you along a golden path of best practices, allowing you to focus on your domain while relieving you from tedious technical tasks.

You can find core documentation for CAP in capire.

Begin with the Getting Started section, as that will take you through the basics as well as detailing some best practices and reference material.

You can also find what’s new in the new Release Notes section.

SAP Developer Center 

In the SAP Developer Center, there are missions, tutorial groups and tutorials.

In the beginner-level mission “Take a Deep Dive into OData” there’s a tutorial group “Build Your First OData-based Backend Service” which gives you a high level taster.

If you’re feeling more adventurous, or more hungry for knowledge and insight, there are a couple of complete missions available too:

The mission Use CAP and SAP Cloud SDK to Extend S/4HANA uses CAP to mock an S/4HANA API, call it with SAP Cloud SDK, and build out a custom app with CAP that uses custom logic to consume that S/4HANA API as part of the business domain design. This mission is designed to give you a good understanding of the fundamental building blocks for extending S/4HANA in the cloud.

I wrote a blog post explaining this mission and giving you a helicopter view of what’s involved: Mission “Use CAP and SAP Cloud SDK to Extend S/4HANA” – an overview.

The mission Build a Business Application Using CAP for Node.js guides you through developing a business application using CAP. Start on your local environment and deploy to SAP Cloud Platform.

If you’re of the Java persuasion, there’s a similar mission you may like – Build a Business Application Using CAP for Java:

You can also find other tutorials tagged with “SAP Cloud Application Programming Model” via this URL:

https://developers.sap.com/tutorial-navigator.html?tag=software-product-function:sap-cloud-application-programming-model

and you’ll be presented with appropriately filtered content like this:

 

SAP Community

Here on the SAP Community you’ll find an array of posts talking directly or indirectly about CAP. You can find the complete set using the tag:

SAP Cloud Application Programming Model

Daniel’s post “Introducing the new Application Programming Model” is a great place to start.

There’s also a dedicated topic page which you should definitely check out: https://community.sap.com/topics/cloud-application-programming – this has all sorts of links including a summary of the latest blog posts and also the latest Q&A, which you can get to directly too via the tag specifically for CAP related questions and answers.

 

SAP TechEd sessions

CAP has proved to have been a popular topic in the sessions and in the corridors at SAP TechEd. There was an array of sessions at SAP TechEd Barcelona – check out the Agenda Builder to find out more.

Here are a couple of them:

  • CNA376 “Build Applications with the Programming Model on SAP Cloud Platform” – hands-on workshop (2hr)
  • CNA652 “Less Than One Hour to a SaaS Application with SAP Cloud Platform” –  CodeJam (mini-edition) (1hr)

The exercise material “spaceflight” for CNA376 is on GitHub for both Node and Java.

If you’re wanting a brief overview of CAP, you could watch this brief (7min) interview between the wonderful Gregor Wolf, and me, from SAP TechEd 2019 in Barcelona: CAPM for Developers, Barcelona 2019:

Tools

If you have a look at the exercises for CNA376 you’ll see they’re for a Node.js (JavaScript) runtime. As well as tools and features for the Application Programming Model being available in the SAP Web IDE Full-Stack, there’s also an extension for Visual Studio Code.

Read more about this extension in Joerg Mann‘s post “Introducing Core Data & Services (CDS) for VS Code” and grab it from the Visual Studio Marketplace – find out more in the tools section of the CAP documentation.

What’s more, there’s CAP support in the new SAP Business Application Studio too!

 

Other media

On SAP’s unofficial community podcast, Coffee Corner Radio, there’s a 16 minute pod bite (#5) where I interview Rui Nogueira on the Application Programming Model.

On SAP CodeTalk, there’s a short interview with Ian Thain and me talking about CAP at a high level: https://www.youtube.com/watch?v=GhEpcB7x4UA

On the SAP Mentors GitHub organisation there’s a repo representing CAP community activity – check it out at bit.ly/cap-com.

If you like to learn by watching folks hack around on screen, and perhaps also take part, then you probably want to check out the Hands-on SAP dev series of live streams which cover all sorts of SAP development topics including of course CAP. Check out the recordings of past episodes here: bit.ly/handsonsapdev#replays.

That’s what comes to mind to me this evening – if there’s anything else (please let me know) I’ll add it to this post as and when it appears or occurs to me.

Happy hacking!

 


Updates:

11 Oct 2018 – added link to SAP CodeTalk interview; added link to Java exercise materials for CNA376

21 Dec 2018 – replaced reference to the original user tag applicationprogrammingmodel with the new tag SAP Cloud Application Programming Model (hat tip to Mike Doyle for the reminder)

03 Jan 2019 – added info on finding tutorials by tag via a URL (hat tip to André Pfohlmann). Also added info on how to see what’s new with the Application Programming Model, via an answer in the Community Q&A from Jijo Roy Jacob 

25 Mar 2020 – major update with huge help from Former Member 

28 Sep 2020 – new location for VS Code Extension

19 Comments
You must be Logged on to comment or reply to a post.
  • Thanks DJ. I started to investigate this topic a while ago thanks to one of your posts and it’s good to have all the resources in one place.

    I’m also working with XSA and I really hope that SAP will consolidate everything because it gets a bit frustrating to have different tools and techniques for on prem and cloud. Web IDE for SAP HANA, Web IDE Full stack, APM in the cloud but not on prem etc.

    Pierre

    • Hey Pierre, thanks, you’re welcome. I’m glad you’re investigating, I am too, it’s a fascinating area and one that I see as very important.

      I think there are things that can be consolidated, but at the same time, we have different requirements too that have to be catered for. With APM – you may be happy to find that you can do stuff purely on prem too, certainly from a development perspective (and then deploy to CF etc later). For example, I’ve used Node.js and sqlite as a persistence layer locally on my machine here.

      That said, it’s early days and I’m looking forward to see how APM pans out even more. Cheers!

    • The application programming model is also planned to come to HANA/XSA on premise in a revision to the Web IDE for SAP HANA 2.0 SPS 03 that is due to ship in about 2-3 weeks. So very soon you should have this same functionality there as well. We are already using this version internally and did some demos at TechEd Las Vegas.

  • Thank you for another great blog!   The possibles are endless, aren’t they?  I just downloaded from Github and had to install a lot of different programming languages.   Nope not using that one for awhile but nice to look at the code.

  • Hi DJ,

    i don’t really have a comment about the actual content, which i’m sure is as excellent as any other that you have authored for the SAP Community, but more about your blogging “best practice”.

    i really appreciate listing the actual update at the bottom of the blog page. very often, i see an update to content created by others, but there is no way for me to figure out what the update is about and what has changed. in your case, it’s done perfectly and is showing that you appreciate both the social technology as well as the audience that is the intended consumer of that social content.

    cheers, gm

    • Hey thanks Henrik – the basic answer is yes, it’s possible, in the Java implementation, at least (and they’re working on the Node.js flavour too). I’ve reached out to a colleague for an example of what to do, and will post here when I receive the info. HTH!

  • Hi,

     

    I tried cds for nodejs and created a small service in VS Code. When I start the service local with “cds serve all”  the service is only available as Odatav4. The Metadata shows

    <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">

    I would like to use Fiori Elements as Frontend, but Fiori Elements seems only supporting Odata V2. Is there a way to switch to Odatav2 in the service?

    I’ve already tried this in package.json, without success:

        "odata": {
          "version": "v2"
        }

     

    best regards,

     

    Harald

    • Thanks Mike, I’d changed all the applicationprogrammingmodel tags for my and my colleagues’ posts here (I’d been semi-involved in the formation of the new tag internally) but forgot to make the change in the content here. Cheers for the reminder – now done!

  • DJ,

     

    thanks for for the blog

    1) Where is the reference for building the CDS data model file, and for building the OData service (cat-service)?

    2) if I want to make certain fields of an entity read only, do you suggest doing that in the service or in the UI? Either way, how do I do that?

    Daniel

    • Hey Daniel, I didn’t write an entire blog, just one post – but thanks 😉

      To your questions, briefly (tho I would recommend any Q&A be made in answers.sap.com):

      1. Follow the documentation link in the first part of this post, and have a look specifically at the “Core Data and Services (CDS) Language Reference” section
      2. You can use annotations for this (there’s a subsection in the language reference mentioned above) – have a look specifically at the @readonly annotation. Depending on requirement, it can be done at either level.

      Cheers!

  • Hi DJ,

     

    I was following the tutorial:

    https://developers.sap.com/tutorials/cp-apm-nodejs-create-service.html

    two issues:

    1. Even though I ran
      npm i -g @sap/cds​

      I see in my Visual Code editor it’s not recognizing:

      using { Country, managed } from ‘@sap/cds/common’;
    2. Even though I commented the dependencies and trying to run the cds by cds run, I am getting the following error:

     

    C:\cloudsdk\cap-node\my-bookshop>cds run

    { Error: Cannot find module ‘express’
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at module.exports (C:\Users\i304296\AppData\Roaming\npm\node_modules\@sap\cds\server.js:6:21)
    at serve (C:\Users\i304296\AppData\Roaming\npm\node_modules\@sap\cds\bin\serve.js:39:46)
    at run (C:\Users\i304296\AppData\Roaming\npm\node_modules\@sap\cds\bin\run.js:31:44)
    at main (C:\Users\i304296\AppData\Roaming\npm\node_modules\@sap\cds\bin\cds.js:66:18)
    at Object.<anonymous> (C:\Users\i304296\AppData\Roaming\npm\node_modules\@sap\cds\bin\cds.js:27:3)
    at Module._compile (module.js:635:30) code: ‘MODULE_NOT_FOUND’ }

     

    Could you please give any clue what am I missing?

  • Thank you for updating this. I have still trouble to get the “Service SDK” layer though. Is there any documentation about that?

    There used to be a “SAP Cloud Platform SDK for service development” (e. g. https://blogs.sap.com/2017/10/17/introducing-the-sap-cloud-platform-sdk-for-service-development/)

    It included, for example, an OData Query generator, built on Olingo. Does it still exist? Where is the documentation?

    Also I find it unfortunate that most documentation is tutorial based. This is great to get started, but then I would rather read a comprehensive reference documentation instead. Copy&paste programming from tutorials is not my goal.

     

    • Hey Christian, thanks for the question – let me get in touch with some folks internally and see if they can help out here. Cheers! DJ