SAP Cloud Application Programming Model, also referred to as SAP CAP, is a framework of tools, languages, libraries and APIs that combine open-source and SAP provided tools and technologies.
A very important aspect of SAP CAP is that it provides SAP best practices to help developers reduce their coding efforts. SAP CAP provides re-useable code to handle common application features. The idea behind CAP is that it encourages developers to focus on the added value part of the application (the domain) and not on the low value recurring, technical features of an application that can easily be provided by the model and that could change across different environments. This means that the highest value parts of applications are safeguarded in a world of fast changing cloud technologies.
SAP CAP is used for new application developments and also to extend existing SAP applications.
CAP is used to develop applications that are deployed to the SAP BTP, Cloud Foundry environment.
The backbone of CAP is Core Data Services (CDS)
CDS is used to define the core data layer. CDS is a semantically rich data definition language. CDS is used to define the physical data layer (e.g. data types, tables) and also to the virtual data layer (e.g. views)
CDS also includes an advanced querying language called Core Query Language (CQL). It enhances standard SQL with elements to easily query deeply nested object graphs and document structures.
A key concept within CAP is that everything is a service. Services expose a consistent set of APIs that can be consumed by all other services and front ends. Services are defined in CDS and define what should happen and when and to what data.
Everything in CAP happens in response to events. Applications built using CAP can transmit events which can be picked up by other services or front-ends using subscriptions. Application can also receive incoming requests and trigger services. Events are managed using event handlers. The CAP models provides generic handlers for common tasks (e.g. CRUD operations, validations) and these generic handlers take care of most of the tasks and use cases. You can also develop custom logic to extend the generic handlers using Java or Node.js.
With CAP you can also create native HANA Cloud database artifacts such as tables, views and functions and mix them with CDS artifacts.
CAP guides developers on a path that follows SAP best practices for developing cloud applications on the Cloud Foundry environment.
With the CAP approach, SAP recommends extensive use of CDS to define models and services so that you are working at the abstraction layer and not developing technical objects directly. This means, as underlying technologies change, your development is able to adapt.
But CDS cannot handle custom logic. For example a complex validation for a combination of additional input fields that are not part of a standard data model. That is when Java and Node.js are used to provide the custom logic.
The recommended tool for developing CAP applications is Business Application Studio because is provides SAP plug-ins and features that are aligned with the CAP approach.