SAP CAP: Cloud Application Programming Model: Deep Dive

What is it, and how can I use it as a developer?

For several years now, SAP has made a new technology available for building custom applications. In addition to being able to build Fiori applications as developers using existing technologies via SEGW services and RAP, we can now also do so with CAP. In the previous article on CAP, you learned the basics of what it is and what benefits it offers your organization. In this article, we’ll take a closer look at the technology and you’ll learn more about what you, as a developer, can actually do with it.

What is CAP?

In case you haven’t read Part 1, here’s a brief summary: CAP is nothing more and nothing less than a framework of programming languages, code libraries, and tools that can be used to build large-scale applications. It implicitly relies on proven best practices and many out-of-the-box solutions for common tasks. This fairly abstract definition already reveals an important aspect of CAP: it is a set of building blocks that can be used to build an application.

When using CAP, the focus is on the problem domain rather than on the technology. A developer does not need to worry about the precise technical implementation of, for example, the physical tables in the database; this is all handled implicitly through the definition of the data model in a fairly simple notation. As a result, the developer, together with the functional experts, will need to carefully design this domain model, which automatically shifts the focus to functionality rather than the technical details. CAP discourages the manual implementation of storing technical fields such as unique identifiers, values in different languages, and metadata. Standard solutions are available in CAP for these purposes.

The image below provides the clearest summary of CAP.

INNOV8iON-SAP-CAP-Cloud-Programming
CAP Overview

Without going into too much technical detail, we will explain the various components shown in the image.

Platforms and Infrastructures

We’ll start at the bottom with the light gray block labeled “Platforms and Infrastructures.” The image above shows that CAP can be used on and with various platforms and infrastructures. CAP applications can be deployed on platforms such as Cloud Foundry and can utilize data from on-premises systems.

Runtimes

The “Runtimes” section above indicates that the actual technical implementation can be done in multiple programming languages. For now, a developer can choose to build the CAP application in Java (Spring framework) or in JavaScript (Node.js framework).

CAP as the hub of the system

Next, we arrive at the core, the “CAP” block. Within this block, we see four different blocks. “Core data services” are the definitions of our data models—in other words, a reflection of our problem domain. “Enterprise services” are the definitions of the data services and their underlying logic. You can think of this as a projection of our data model. Here, we specify which data from the model is made visible, how that is done, what you can do with that data, and what custom logic is built in. “Connectors” means that we can incorporate various services from the BTP, or from external sources (such as third-party and open-source products), into our application. The “Identity & Auth” service is a key feature here; this service can handle user authentication within our application. This also covers the entire “Platform services” block on the right. Finally, in the center, we have the “Adapters” block. This block indicates that we can make our services—which are built on our data model—available to a front-end application using various techniques. Think, for example, of the well-known OData service definition, which many SAP developers are familiar with. Once again, the developer is free to choose what best suits the use case. This also highlights the “Protocols” block.

Front-end

That leaves us with one more block: the top one, “Front ends.” This block indicates that different UIs can be built within a CAP application. This allows you to build physically distinct applications on a single service, but you can also choose different UI technologies. You can use well-known SAP technologies such as SAP Fiori Elements and SAPUI5, but you can also choose to use other popular UI frameworks like React or Vue.js.

In summary, a CAP application is composed of various building blocks that can be used to create a full-stack application for a wide range of different use cases.

Benefits of the CAP

We can conclude that SAP CAP allows developers to select the building blocks—from SAP and other vendors—that are needed to build an application for a specific use case. By using these building blocks, the development of a CAP application is relatively flexible; the data model can be easily adapted or expanded as the application grows or changes. SAP refers to this as the “grow-as-you-go” concept. SAP CAP automatically offers many out-of-the-box capabilities, allowing developers to get a working application up and running relatively quickly with common functionalities that would otherwise have taken a long time to implement. Because CAP utilizes a wide range of well-known technologies from around the world, you are not dependent on a single vendor; there are always alternatives (bothproprietary and open source!). This prevents vendor lock-ins.

In practice

Would you like to implement CAP in your organization, or are you curious about how CAP can be used? Then read this blog post about the ways CAP can be used within your organization.

Opportunities for You as a Developer

Are you interested in getting started with this technique? Feel free to contact us. At INNOV8iON, we also offer training courses on developing CAP applications; take a look at our information page about the CAP training.