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
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.
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.
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.
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 com.sap.cloud.servicesdk.prov:odatav4 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.