Skip to Content
Product Information
Author's profile photo Artem Kovalov

SAP Cloud SDK – April 2021 Release Highlights

Welcome to the April 2021 issue of the SAP Cloud SDK release highlights!

March in numbers:

    • 26 issues and support incidents received
    • 16 of those were answered or solved and closed
    • 4.75K clicks from search in Google guiding to our documentation portal

Latest documentation updates

SAP Cloud SDK for Java 3.43.0

Quick links

OData v2 Received an Update to Change Sets API for Batch Requests

We continue unifying OData v2 and v4 APIs, now it’s the time of ChangeSet requests in Batch. Improved API allows handling each request more granular in the ChangeSet by adding specific headers to each request or making different configurations. To get an idea how it looks like, check the code snippet below:

// define modification requests including custom headers per request
MyEntityCreate createRequest = new MyEntityCreate(myNewEntityInstance).withHeader("custom-header", "value");
MyEntityUpdate updateRequest = new MyEntityUpdate(myUpdatedEntityInstance).withHeader("another-custom-header", "another value");

// assemble batch request by adding both modifications into a single changeset
MyEntityBatch batchRequest = new MyEntityBatch().addChangeSet(createRequest, updateRequest);

// execute the batch request
BatchResponse response = batchRequest.executeRequest(myDestination);

 

Improved API for PATCH Requests in OData with Complex Properties

We improved OData v4 update requests that use the PATCH HTTP method. Now they allow adding complex properties without the need to use setters for each value inside the complex property. You can use the builder pattern or the constructor to propagate the property values.

Before the API looked like this:

Entity entity;
ComplexProperty property = new ComplexProperty();
property.setValue("Foo");
entity.setComplexProperty(property);

The improved API looks like this:

Entity entity;
entity.setComplexProperty(new ComplexProperty("Foo"));

We automatically detect transient changes in complex properties when doing updates.

Improve OData Code Generator to Prevent Breaking Changes

In the latest S/4HANA release, we identified services changing the order of parameters in function imports and get-by-key requests. This would lead to breaking changes in the Fluent APIs produced by it. For that reason, we introduced a new default by overridable behavior to keep the order of the parameters even if the specification doesn’t preserve it. Use the XML snippet below if you want to override the default behavior and have the parameters order from the specification.

<keepExistingSignatures>false</keepExistingSignatures>

This update made it possible to release an updated version of the following services:

  • Purchase Requisition – API_PURCHASEREQ_PROCESS_SRV
  • Production Order Confirmation – API_PROD_ORDER_CONFIRMATION_2_SRV
  • Process Order Confirmation – API_PROC_ORDER_CONFIRMATION_2_SRV
  • Attachments – API_CV_ATTACHMENT_SRV

How to update?

Navigate to a root folder of your project and find a pom.xml file. Bump the version of com.sap.cloud.sdk dependency to 3.41.0 similar to the XML code snippet below and you’re done! Mind, because Maven Central relying on CDN it takes a bit of time for the new maven module to be distributed.

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

If for some reason your IDE hasn’t fetched an updated dependency version, run mvn clean install from the command line in the root directory of your project.

SAP Cloud SDK for JavaScript

Quick links

OpenAPI Type-safe Client is Generally Available

It is with great pleasure that we announce you can now use OpenAPI code generator and type-safe client by SAP Cloud SDK for Typescript and JavaScript productively.

We have tested the OpenAPI code generator on all the OpenAPI 2.0 and 3.0 services that can be found on the SAP API Business Hub as of April 2021. From the total of 772 specifications, 736 were successfully generated and compiled which represents 95.3%.

We’re working on the remaining 36 services to make sure they are also compliant with the SAP Cloud SDK. This includes investigation of failure reasons and fixing the generator or providing feedback to service providers about defective specifications.

Take a look at our documentation to learn how you can significantly simplify dealing with OpenAPI services leveraging the SAP Cloud SDK for JavaScript.

Improved OpenAPI Generator Now considers Vendor Extensions and CSRF Token

By default, we use OpenAPI tags to derive API names for classes and methods. To help with situations when tags are not the best source of names we decided to use OpenAPI vendor extensions x-sap-cloud-sdk-api-name and x-sap-cloud-sdk-operation-nameto help you make your generated client have semantic naming.

To make life easier for application development involving OpenAPI services we introduced automatic handling of CSRF token. This behavior can be suppressed for performance or other considerations. You can also add extra headers as well as pass additional configuration to the underlying axios backend. This way you can support file downloads as in the example below and some other use-cases not possible before.

MyEntity.requestBuilder()
  .getAll()
  .addCustomRequestConfiguration({ responseType: 'arraybuffer' });

Getting Raw Response from an OpenAPI Service

There are situations when a typed response doesn’t contain all the information required for covering development needs. To solve this we allow fetching raw HTTP response. This is helpful for workarounds, debugging, dealing with non-compliant services, and testing while developing your own service. Use executeRaw method to leverage this functionality.

const httpResponse: HttpResponse = MyEntity.requestBuilder()
  .getAll()
  .executeRaw(destination);

Command-line Interface of the SAP Cloud SDK for JavaScript is Deprecated

We decided to deprecate the CLI of the SAP Cloud SDK for JavaScript. Most of its features will be replaced with relevant assets. Follow our release notes and documentation to stay informed about replacement options. You can continue using CLI but it won’t be receiving any updates or bug fixes. This doesn’t relate to OData and OpenAPI generator CLIs.

How to update?

To update the version of the SAP Cloud SDK for JavaScript used in an existing project, use the command npm update in the root folder of your module. Note that this will also update other modules unless you explicitly specify which packages to update. If you want to check beforehand what will change, use npm outdated.

Additionally, you can consult NPM for more information on version history and update path.

Feedback

We hope you enjoy developing with SAP Cloud SDK! To help us further improve give your ideas and suggestions in the comments to this blog or create an issue in our GitHub repository.

All the best,

SAP Cloud SDK Team

Assigned tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.