Integration With Cloud Application Programming Model

This document outlines how you integrate the SAP Cloud SDK into an application based on the SAP Cloud Application Programming Model (referred to as CAP in the remainder).

Check out the tutorial as well

While this document provides a general overview of this topic, we have published a practical tutorial on SAP Developers which illustrates all steps on a comprehensive example.

Integration Steps#

Assumption

The following instructions assume that you have an existing CAP project that can be built successfully. Furthermore, we assume that you deploy your app to the SCP Cloud Foundry environment.

Add the SAP Cloud SDK Bill-of-Material#

Add the SAP Cloud SDK Bill-of-Material (BOM) into the dependencyManagement section of the root POM. Here is the XML snippet:

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.sap.cloud.sdk</groupId>
<artifactId>sdk-bom</artifactId>
<version>use-latest-version-here</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Use latest SAP Cloud SDK version

We recommend using the latest SAP Cloud SDK version always. Check out the release notes to see the release history.

Add the SAP Cloud SDK Dependencies#

Add the respective SAP Cloud SDK dependencies to the POM file under the srv directory.

<dependency>
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>
<artifactId>scp-cf</artifactId>
</dependency>
<dependency>
<groupId>com.sap.cloud.sdk.s4hana</groupId>
<artifactId>s4hana-all</artifactId>
</dependency>
Version information controlled through the SAP Cloud SDK BOM

Note that the version tags can be omitted, because the previously added the SAP Cloud SDK BOM controls the version of all the SAP Cloud SDK modules. That is, you only need to increase the version of the BOM and all modules get updated automatically.

tip

The two mentioned dependencies are modules that cover a broad range of possible the SAP Cloud SDK use cases. You may choose a more fine-grained selection of the SAP Cloud SDK dependencies according to your specific use case.

Add the Integration Dependency#

If your app uses multitenancy features and/or a protected backend, we have to integrate the tenant and user concepts of CAP and the SAP Cloud SDK. We'll add a respective integration dependency to the POM file under the srv directory (same place as the previous step).

<dependency>
<groupId>com.sap.cds</groupId>
<artifactId>cds-integration-cloud-sdk</artifactId>
</dependency>

Enable the Component Scan for SAP Cloud SDK Package#

Let the Spring component scan crawl the SAP Cloud SDK package. We'll annotate the Spring Boot application class which is annotated with @SpringBootApplication as follows.

@ComponentScan({"com.sap.cloud.sdk", "com.mycompany.myapplication"})
@ServletComponentScan({"com.sap.cloud.sdk", "com.mycompany.myapplication"})

Make sure that you also add the package name of your application.

Integration finished

Now the SAP Cloud SDK is integrated with the CAP application. You can go ahead using the SAP Cloud SDK features, such as querying OData services.

Last updated on by Artem Kovalov