Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
The new version of the SAP S/4HANA Cloud SDK Java libraries is available since today. You can update your dependencies to version 2.0.0 and consume the new version from Maven Central.
In this blog post, we will walk you through the highlights of this major new release. 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.

Visit us from June 5-7, 2018 at SAPPHIRE NOW 2018 at the topic station Extensibility and Integration with SAP S/4HANA (BA333) or attend the following sessions that feature the SAP S/4HANA Cloud SDK in the context of extending SAP S/4HANA.

  • BA60700 - Extend and Tailor SAP S/4HANA to Meet Unique Business Needs

  • PL60852 - Customize SAP S/4HANA to Meet Your Business Needs

  • BA60708 - Adapt SAP S/4HANA to Meet Your Business Requirements

  • PL60853 - Differentiate Your Business with SAP Cloud Platform

Watch out for our new book Extending SAP S/4HANA. Side-by-Side Extensions with the SAP S/4HANA Cloud SDK, in stores since May 30th, 2018. It features the complete end-to-end story of building extensions for SAP S/4HANA using the SAP S/4HANA Cloud SDK, with many code examples and in-depth explanations. The book is already based on version 2.0.0 of the SAP S/4HANA Cloud SDK.

Java Libraries: Release Highlights

Modernized Technology Stack

With version 2.0.0, we drop the support for Java 7, which in turn allows us to modernize our technology stack. As a consequence and as signaled by the new major version, there are multiple changes to the API of the SAP S/4HANA Cloud SDK which require your attention. Transitioning to 2.0.0 should be quick despite these changes, but you may be required to slightly adopt your code to the changed API or behavior.

These changes fall in different categories: we leverage features and APIs of Java 8 where appropriate, clean up the API of the SAP S/4HANA Cloud SDK, change obsolete or unwanted behavior from past versions, update dependencies, and apply consistent naming. Version 2.0.0 thus not only further improves the quality of the SDK, but also opens up the door to further improvements in the future - some of which you already find with this release, mentioned below.

For a complete overview of what has changed, check the list of compability notes in the full release notes.
We have also published a blog post that guides you through the transition to version 2.0.0.

Additional Headers as part of Java VDM OData Requests

The Java virtual data model (VDM) for OData services now allows to supply custom headers to all OData requests. Use the new withHttpHeader method that is available on all fluent helpers and specify the String-typed parameters key and value for the HTTP header. The given key and value will be added to the HTTP headers of all underlying OData requests.

In addition to this option to manually set HTTP headers, the VDM now propagates the SAP client and locale from the ErpConfigContext, if present, into the HTTP headers of all OData requests with the keys sap-client and sap-language. To pass in different values for client and locale than the default, create an ErpConfigContext object with the desired locale and/or SAP client and call the execute() method of the fluent helper with the ErpConfigContext object as a parameter.

Update of VDM to SAP S/4HANA Cloud 1805

Recently, SAP released SAP S/4HANA Cloud 1805.

With version 2.0.0, the SAP S/4HANA Cloud SDK updates the Java VDM (VDM) to SAP S/4HANA Cloud 1805 to support all newly released or updated OData services of an SAP S/4HANA Cloud 1805 system. As explained in the blog post about the VDM itself, the VDM greatly simplifies reading and writing data from an SAP S/4HANA system in your Java code.

You can use the SDK to connect to all OData services listed in the SAP API Business Hub for SAP S/4HANA Cloud.

Further Improvements

We have added a resetChangedFields() method to all VDM entities to reset the currently tracked changed fields for update requests. Usually, a field will be marked as changed and sent in following update requests when its setter method has been called. With the new method, you can mark all previously changed fields as unchanged. Subsequent changes with the setters will be registered again.

For productive applications, it is always required to setup security for as, for example, explained in our tutorial series. Nevertheless, during development and testing it may be helpful to mock the tenant and user information instead of recreating the security setup in the development and testing environment. The SAP S/4HANA Cloud SDK already provided in past versions the ALLOW_MOCKED_AUTH_HEADER environment variable to support this. Version 2.0.0 introduces two new environment variables that can be used for more fine-granular control over mocking at runtime. When you set the USE_MOCKED_TENANT or USE_MOCKED_USER environment variables to true, the application will use a mocked tenant (with value "") or mocked user ("") instead of an actual tenant or user, respectively. These variables should not be used in production, but only for testing purposes. As a consequence, the SDK writes security errors to the log when you use these environment variables. The behavior of the new environment variables is similar to the ALLOW_MOCKED_AUTH_HEADER environment variable on Cloud Foundry, but in contrast to that the new variables work on both Neo and Cloud Foundry and always take precedence over an actual tenant and user.

Our Maven "bill of material" (BOM) now manages the version of the OData v4 provisioning libraries of the SAP Cloud Platform SDK for service development. This allows to quickly use the corresponding libraries with a consistent version by adding to the dependencies of a project. The SAP S/4HANA Cloud SDK version 2.0.0 references version 1.17.0 of the SAP Cloud Platform SDK for service development.

Several further improvements are listed in the full release notes.

How to Update the 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 2.0.0.

With this, you are already done thanks to the "bill of material" (BOM) approach. Your dependency should look like this:
<!-- possibly further managed dependencies ... -->

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 2.0.0.

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