Skip to Content
Technical Articles
Author's profile photo Maximilian Streifeneder

Max’s Adventure in SAP Cloud Platform: CAP in Love.

In this blog post, I want to share my thoughts that have been in my mind in the last half-year. Mainly why the community (and me) enjoys and embraces CAP (SAP Cloud Application Programming Model) the way it is and which reasons it has. Spoiler: I love CAP. You should also give it a try. You will find some arguments in this blog post. 

I had the honor to run 10 SAP CodeJams in the last couple of months all over Europe. if you have no idea what a CodeJam is – there’s a dedicated section at the end of this blog post. Round about 20-40 folks attend a SAP CodeJam usually, where they get introduced to a new topic. All of those SAP CodeJams had the theme “SAP Cloud Application Programming Model”. I had a look at the result of a survey, we as Developer Advocates gave attendees after the event. Mainly to give us a feeling of how we can improve our format, to improve the content and be more empathetic. Empathetic, in a sense whether we expect too much from attendees or if the topic is too advanced or suchlike. And the result is extraordinary. Let me explain why:

99,5% of the attendees would recommend this particular CodeJam to others. (would love to see the other 0,5% commenting below this blog post 😉 ) At this point, I thought about why the result was that outstanding.

Is it because of the way we run CodeJams? – A little bit, could be. But that’s not the crucial ingredient.

Is it because the event is for free? – Not really, folks still have to free time and spent 5-7 hours to attend the event.

Is it because the SAP Cloud Application Programming Model adds value to developers? That’s where I would give a damn yes.

What is the SAP Cloud Application Programming Model?

cap.cloud.sap says: “The ‘SAP Cloud Application Programming Model’ is an open and opinionated, framework of languages, libraries, and tools for building enterprise-grade services and applications. It guides developers through proven best practices and a great wealth of out-of-the-box solutions to recurring tasks. CAP-based projects benefit from a primary focus on domain, instead of delving into overly technical disciplines, significantly accelerated development, and safeguarded investments in a world of rapidly changing cloud technologies.

Basically, I would rephrase it as: It should simplify your life as a developer. Fullstop. Not only because it relieves you of many recurring and tedious tasks that you don’t like to take care of anyway. But also because it offers a uniform way of developing an application along a so-called golden path.

Abstraction for good reasons.

How many times have you analyzed source code from colleagues and spent an eternity getting familiar with project structures and general application setup? From my own experience, this not only costs time but also energy. With CAP, you have a centralized and declarative way of defining your data model and services – no matter which language your custom application logic is written in. How? With CDS – Core Data Services. Below is an example of a data model and a service definition written in CDS. (not to be mistaken with SAP HANA CDS or ABAP CDS, which have similarities but are not the same) On the left side, schema.cds file, with the entity definitions. On the right side, services.cds file, with definitions of how your services should look like.

How does that look to you? Do you have any idea on which database this is running? Do you have any idea, which language the custom application logic is written in? Simply no, because you don’t have to at this level. For instance, it’s not your actual job to define SQL statements. Your data model should compile to an SQL Statement for what it’s needed – i.e., to an SQL statement executable in an SQLite database for local development or to SQL statements executable in an SAP HANA database in a productive environment. Basically the CDS compiler takes your declarative statements and turns them into runtime artifacts needed for your target environment. Because of these two files, you already get full-fledged OData services (CRUD+Q) for your defined entities. For free, just with a couple of lines written in CDS.

Which leads me to the next chapter…

Max: “CAP, lower the hurdle, please!” 

CAP: “Max, Roger that. Sucessfully executed!” – How often have you given a new tool, a new programming language, or a new methodology a try and have given up again? It happened to me quite often because it was either too complicated, I couldn’t distinguish any added value, or the effort was disproportionate. On the contrary: The recent SAP CAP CodeJams showed how quickly folks can create a project and be productive. There’s no need to set up a holistic project with x configurations. Start with a minimalistic set of artifacts and grow as you go. Full-fledged OData services in a local environment running on an SAP HANA in SAP Cloud Platform? Just a matter of seconds. Does that lower the hurdle to get started? 😉

Why is that even possible? Because CAP takes care of the technology-dependent configurations, actions, and files, which are necessary to run an application in such an environment. CAP tackles one of my phrases: “Don’t do technology for the sake of technology”.

One of the arguments I often hear nowadays: “thanks for the possibilities you give me now with all these innovations, but they don’t make my decisions easier. We need guidance.” With CAP, you have clear guidance on how to develop applications with providing out-of-the-box solutions for SAP preferred options like SAP HANA or SAP Fiori but still gives flexibility to breakout wherever you need to.

Serve REST endpoints instead of OData. Provide Vue.js frontends instead of SAP Fiori UIs. Use your preferred editor like vim instead of the SAP Web IDE or SAP Business Application Studio (curious how to pimp vim with CAP features? My colleague DJ Adams shows it in one of his #HandsOnSAPDev recordings). To name a few of the breakout picks.

Abstractions for good reasons. Again.

What if something changes on the Platform side in the upcoming years? We all know that things in IT change frequently, and everybody is trying to stick to a good balance when it comes to adopting new features/technologies. Just think back, what kind of trends were hyped in the last couple of years and are now more or less without any meaning? Don’t get me wrong. SAP is following the right path from my point of view with Cloud Foundry in SAP Cloud Platform, but what if something changes architecture wise in the future?

Safeguarding investment is the appropriate keyword here. Because of CAPs platform and protocol agnostic design and strategy, you are not anymore tightly coupled to a specific technology and leverage from your investment today also in the future. Thanks to the declarative approach, CAP could prospectively take care of needed changes to stay up to date but also safeguard your invested time and efforts.

On a side note: Mock Server needed?

How often did you have the problem to find a fitting OData service to experiment? It’s a matter of seconds to build a CAP application with some test data and, as said, get the entire set of OData operations (CRUD+Q) out of the box. Run it in SAP Cloud Platform or local without tremendous effort. You are in charge of your very own mock server now. It’s a matter of seconds to get it up and running. DJ Adams and Marius Obert have used this approach, for example, for their SAP TechEd Mission “Use CAP and SAP Cloud SDK to Extend S/4HANA to mock an S/4 HANA system, so that everybody has its very own mock server running locally.

Community engagement

One of my main tasks as a Developer Advocate is: Listen to developers and think about what feedback they provide. And I’ve seen excellent traction in the community about the Adoption of CAP. There’s already a dedicated GitHub repository with a focus on providing example source codes.

I asked a couple of the community members explicitly:

How do you think about CAP?

Volker Buzek: “CAP (Node.js) has put me as close to a full-stack engineer as I never wanted to be :-). It is lightweight, sporting a modular reflection design, favoring convention over configuration – which takes down the entry hurdle significantly. And its’ declarative usage for service + persistence modeling feels like a breeze of fresh air in the complex SAP software universe.”

Benjamin Krencker: “I like CAP because I am able to build modern web apps with db, OData service and UI in a really short time! And I can also profit from enterprise features such as authentication and internationalization.”

Gregor Wolf: “Get ideas quickly into a fully CRUD enabled OData API that serves a Fiori Elements UI. But be aware that Fiori Elements you must use OData V2 as SAPUI5 is lacking quite a bit for V4. I hope that CAP  will follow OpenUI5 and get open sourced to get a big userbase.”

You want to get started, but you don’t know where to start?

Here’s my list of suggestions:

Tutorials: 
Build a Business Application Using Node.js
Use CAP and SAP Cloud SDK to Extend S/4HANA
Build Your First Full-Stack App on SAP Cloud Platform

Blogs:
https://blogs.sap.com/tags/9f13aee1-834c-4105-8e43-ee442775e5ce/

Livecoding:
#HandsOnSAPDev with qmacro

Documentation:
cap.cloud.sap

Community (GitHub):
– bit.ly/cap-com

SAP CodeJam: 
https://community.sap.com/events/codejam

You don’t know what a CodeJam is? Hold on:

community.sap.com: “SAP CodeJam is a developer community focused event, requested by you, where you can check out specific SAP technology, platforms and tools through simple, end-to-end scenarios. The events are supported by SAP and led by SAP experts who will be onsite to guide you through the exercises, answer your questions, and share relevant insights and tips. SAP CodeJam are hands-on events where you need to bring your own machine and plan to spend between 5-6 hours learning, networking and collaborating.”

All of that for free, except the fact that the requester has to provide a room + WIFI.

Experience Reports of recent CodeJams: 

CAP CodeJam at KMD in Copenhagen
CAP CodeJam at Foriba in Istanbul
CAP CodeJam at SAP Hellas in Athens
CAP CodeJam at Capgemini in Wroclaw

CAP CodeJam at minnosphere in Passau

 

 

 

Assigned Tags

      13 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Tarun Jain
      Tarun Jain

      Great blog Max !

      I would like to understand more about how does CAP fit into SAP onPrem HANA development and XSA/HDI . We have examples of deploying to  SQLite database and I used the same to develop Node module and Odata V4 in SAP Cloud WebIDE to deploy it on HANA CF environment. Can these be extended to deploy to SAP HANA from VS Code without WeBIDE ,  what additional steps needed for deploying to SAP HANA ? SAP HANA WebIDE is not completely same as SCP WebIDE what are the limitations of CAP if using for onPrem HANA.

      Thanks,

      Tarun

       

      Author's profile photo Maximilian Streifeneder
      Maximilian Streifeneder
      Blog Post Author

      Hi Tarun,

      thanks for your question. To be honest, I haven't tried it yet. Could you assist here, Christian Georgi?

      Author's profile photo Tarun Jain
      Tarun Jain

      Thanks Max,

      While I was asking this question here.. found this excellent 4 part blog..  latest post from today answers some of the questions I had regarding deploying local CAP project to SAP HANA.‬

       

      Regards,

      Tarun

      Author's profile photo Maximilian Streifeneder
      Maximilian Streifeneder
      Blog Post Author

      ah,then I misunderstood you. thought you want to deploy it to a on-premise SAP HANA. with the latest @sap/cds-dk version it's possible to simply deploy it to SAP HANA in SAP Cloud Platform using the following command:

      cds deploy --to hana

      You need to be logged in to SAP Cloud Platform Cloud Foundry using the CF CLI before.

      Author's profile photo Tarun Jain
      Tarun Jain

      No you got it right.. I want to deploy to onPrem HANA,  but this blog gave me some direction that it can be done as we have a mtar it could be deployed to HANA with XS CLI / HANA WebIDE.

       

      Author's profile photo Gregor Wolf
      Gregor Wolf

      Hi Tarun,

      I'm involved in a product development that extends a SAP HANA Native onPremise solution. We've choosen CAP instead of XSOdata and the XSA programming model. It nicely works together with HANA onPrem. And with the help of the post Developing with HANA Deployment Infrastructure (HDI) without XSA/CF or Web IDE from Thomas Jung I have now a local development setup with the SAP Standard solution deployed in one HDI container and our addon in another. And that in the DB only HANA Express Edition.

      Today we had to implement a new Entity and that took me from definition to draft enabled Fiori Elments UI arround 30 minutes.Join the CAP Community also on Slack to excange with us when you run into issues.

      Best regards
      Gregor

      Author's profile photo Helmut Tammen
      Helmut Tammen

      Great blog Max, thanks a lot

      Helmut

      Author's profile photo Harikishore Sreenivasalu
      Harikishore Sreenivasalu

      Great Blog and reflection. We are busy migrating our HANA Application on Neo to Cloud Foundry CAP application. will share our learning soon, once the application is live.

      Author's profile photo Serdar Simsekler
      Serdar Simsekler

      Hi Max

      Really nice to see such a passion. And I am starting to love CAP, too. I have some feedback hoping it helps:

      • We need more online tutorials/samples touching different type of real-life problems solved with CAP:
        • Current tutorials touch only on creating a new application/extension? How about if I need to update an existing application/extension? How about if I am writing a new application using existing database artefacts?
        • How do I add a new UI module?
        • Can we get an example based on a real-life enterprise-y scenario demonstrating end-to-end lifecycle of an application with all possible modules (custom UI, DB, backend, authentication, authorization, CI/CD, etc.) built and updated with CAP? Asking for too much? ?
          1. Say, for example, for a high school, we need an application where teachers can  publish a list of after-school elective/optional courses they offer and students can register for the courses they are interested in.
            1. The list of courses are visible in teacher’s profile page which is public
            2. The course details can be viewed in course page which is public
            3. When logged in, in their profile page a teacher can
              1. add a new course (course title, description) they offer
              2. update an existing course they offer
              3. delete an existing course they offer
            4. When logged in, a student can register to a course
          2. One of the pages can be based on how CAP generates, the other can be a custom one built in SAPUI5.
          3. Pages are available to public and shows extra content as above when he user is logged in.
          4. There are three developers (Team A) working on this; so, the code must be in a SCM system, e.g. Git
          5. Variations for backend (Node.js and Java)
          6. Variations for DB (SAP HANA, Azure SQL Database, Azure Database for PostgreSQL)
          7. Deployment with automated CI/CD (How this connects to Project Piper or hopefully new set of DevOps tools in SCP)
          8. Team B wants to develop a new page which lists all courses offered. How can they make use of existing DB artefacts (with no change to them) to create their page as a separate project.
          9. Team C wants to develop a new page which lists courses a student is registered to. They need to extend the existing data model (e.g. add registration date to student course registrations table) to create their page as a separate project.
        • –> I know some of the above are not necessarily CAP’s own concern; but, if CAP is also a set of best practices, I believe it needs to cover more then its core.
        • –> I can see this is a wide context; but, why would not CAP have a showcase application to demonstrate all the best practices woven around CAP core. Does this make sense?

       

      • Is there a roadmap we can check?
        • When will CAP officially support PostgreSQL?
        • Any plans for other DBs especially if the DBs are in other hyperscaler cloud (Azure SQL Server, Azure Database for PostgreSQL?

      I am aware there is an openSAP course planned in April and I am hoping aforementioned questions will get answers there.(cc Christian Georgi )

      I know there is quite a hard work behind all this and would like to see more of it. ?

      Kind Regards

      Author's profile photo Daniel Wroblewski
      Daniel Wroblewski

      Max, nice blog

      Author's profile photo Amaury VAN ESPEN
      Amaury VAN ESPEN

      Nice blog post

      very engaging. Thank you Maximilian Streifeneder

      Author's profile photo Maximilian Streifeneder
      Maximilian Streifeneder
      Blog Post Author

      Thanks Amaury Van Espen, glad I could help!

      Author's profile photo Devilliers Ferdrich MAKOUANGOUH
      Devilliers Ferdrich MAKOUANGOUH

      This blog opens my mind on CAP ,reinforce my skills . Million thanks Maximilian Streifeneder