Skip to Content

The new version of the SAP S/4HANA Cloud SDK Java libraries is available since today. You can update your dependencies to version 1.9.4 and consume the new version from Maven Central.
In this blog post, we will walk you through the highlights of these releases. For a complete overview, visit our release notes for the Java libraries. The release notes also include the change log of all our releases so far.
At the end of the article, you will find a set of instructions on how to update to the new version.

Java Libraries: Release Highlights

OAuth2 SAML bearer flow with Cloud Foundry destination service

The OAuth2 SAML bearer flow is used when an application on SAP Cloud Platform accesses an destination such as an SAP S/4HANA system and the calling application wants to propagate the currently logged-in user to the called destination (principal propagation). The destination service in the Cloud Foundry environment of SAP Cloud Platform allows creating a destination with OAuth2SAMLBearerAssertion as authentication type.

With version 1.9.4 of the SAP S/4HANA Cloud SDK, we transparently support the OAuth2 SAML bearer flow in the Cloud Foundry environment as part of our SAP Cloud Platform abstractions. When you send a request to a destination configured with OAuth2 authentication, the SAP S/4HANA Cloud SDK handles the necessary authentication flow in the background. You only need to set up the correct bindings to the destination service and the UAA service. See this tutorial for an explanation of the same concept for the Neo environment of SAP Cloud Platform. The explanations therein in general apply also to Cloud Foundry, especially on the level of the source code and configuration in SAP S/4HANA.

Preview release of Virtual Data Model (VDM) generator

This version contains a preview release of the Virtual Data Model (VDM) generator for OData services. The preview of the VDM generator is meant to gather feedback, but not yet meant for productive use. The API and functionality of the later full release may differ from the preview release.

The SAP S/4HANA Cloud SDK provides a Java virtual data model for OData services of SAP S/4HANA Cloud. The VDM allows to easily access SAP S/4HANA Cloud APIs in a fluent and type-safe manner, as described in the corresponding blog post. The VDM delivered with the SAP S/4HANA Cloud SDK gives access to the public API of SAP S/4HANA Cloud (and SAP S/4HANA) published in the SAP API Business Hub. The VDM generator preview gives you the option to quickly generate your own VDM for your custom OData services. These custom services can, for example, be based on custom business objects or custom CDS views, created with the in-app extensibility capabilities of an SAP S/4HANA Cloud system.

The preview release requires two artifacts for each OData services for which to generate a VDM: the metadata document as an EDMX file and a Swagger file in JSON format. You can simply download the EDMX file from your OData service by appending /$metadata to the URL. For the Swagger files currently required by the VDM generator, we provide templates in our GitHub repository. Download the appropriate template for your use case, adapt it to your OData service as described in the how-to, and store it together with the EDMX file in one folder that we will use as input for the generator. Both files should be named with the technical name of the OData service (for example YY1_MYBUSINESSOBJECT_CDS) and the corresponding file extension (.edmx and .json, respectively).

Afterwards, to run the generator, follow these simple steps:

  1. Download the command line interface of the generator and put it in a folder of your choice.
  2. Run java -jar odata-generator-cli-1.9.4.jar -h on the command line within that folder to see the available options of the command line interface.
  3. Run the generator as follows: java -jar odata-generator-cli-1.9.4.jar -i /path/to/input /folder -o /path/to/output/folder.
    You can also specify the parameter -p my.package.name to choose the package name.
  4. Wait for the generator to finish with a success message. This will only take one or two seconds.
  5. Put the generated Java source files from the output folder into your project that is using the SAP S/4HANA Cloud SDK so that they are picked up by Java. For example, move them to the application/src/main/java folder.
  6. Finally, you need to add lombok to the dependencies of your project. Add the following to the dependencies section of your application/pom.xml file:
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <scope>provided</scope>
    </dependency>​

Now, you can use the generated classes in your Java code to access your custom OData service with the same simplicity, type-safety, and ease-of-use that you know from the VDM for the public API of SAP S/4HANA Cloud.

The above is just one possible option to use the generator. There is also a Maven plugin com.sap.cloud.s4hana.datamodel:odata-generator-maven-plugin available to generate the VDM as part of the Maven lifecycle. Furthermore, you can call the generator from any Java application via the DataModelGenerator builder class. Future releases will bring further improvements to make the use of the generator and the resulting VDM even easier.

Further Improvements

All archetypes of the SAP S/4HANA Cloud SDK now contain the cx-server script for the latest version v6 of the Continuous Delivery toolkit, so that you can start the out-of-the-box Jenkins server from the archetype, including the new features for backup and restore as well as the download cache.

We fixed an issue where a DestinationAccessException occurred on SAP Cloud Platform Cloud Foundry when a subaccount had an on-premise destination configured and the application was not bound to a connectivity service instance, even if this destination was never used.

More details on this and further improvements are listed in the full release notes.

How to Update: Java Libraries

To update the version of the SAP S/4HANA Cloud SDK Java libraries used in an existing project, proceed as follows:

  • Open the pom.xml file in the root folder of your project.
  • Locate the dependency management section and therein the sdk-bom dependency.
  • Update the version of that dependency to 1.9.4.

With this, you are already done thanks to the “bill of material” (BOM) approach. Your dependency should look like this:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.sap.cloud.s4hana</groupId>
            <artifactId>sdk-bom</artifactId>
            <version>1.9.4</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
    <!-- possibly further managed dependencies ... -->
</dependencyManagement>

You can now recompile your project (be aware of the compatibility notes, though) and leverage the new features of the SAP S/4HANA Cloud SDK in version 1.9.4.

Of course, you can also generate a new project that uses version 1.9.4 from the start by running the Maven archetypes for Neo or Cloud Foundry with -DarchetypeVersion=1.9.4 (or RELEASE).

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply