The original link

For TypeScript and JavaScript developers, this is for you: The SAP Cloud SDK (FKA SAP S/4HANA Cloud SDK) is now available for JavaScript. Today, we are proud to release version 1.0.0 of the SAP Cloud SDK for JavaScript. This is the first general purpose, efficient version of the JavaScript library since the beta version began last October.

Similar to the SDK for Java, the SAP Cloud SDK for JavaScript makes it easy and enjoyable to develop extensions to SAP S/4HANA into applications on the SAP Cloud Platform. The SAP Cloud SDK for JavaScript helps you integrate SAP S/4HANA into Cloud native applications written in TypeScript or JavaScript and running in Node.js. You can execute these applications locally, or you can deploy them to the SAP Cloud Platform, Cloud Foundry.

Easy access to SAP S/4HANA Cloud APIs

Accessing the SAP S/4HANA Cloud can be as simple as this — no boilerplate, low-level code, just business logic:

import { BusinessPartner } from '@sap/cloud-sdk-vdm-business-partner-service';

BusinessPartner.requestBuilder()
    .getAll()
    .select(BusinessPartner.LAST_NAME)
    .filter(BusinessPartner.FIRST_NAME.equals("John"))
    .execute({destinationName: "S4HANACloud"})
    .then(businessPartners => {
        // process result of type BusinessPartner[]
    }).catch(reason => {
        // handle error
    });

This is achieved through the OData Virtual Data Model (VDM, also known as the Java SDK). The OData VDM for the JavaScript SDK provides TypeScript/JavaScript representations of the SAP S/4HANA Cloud’s OData API. Include all the service, operation, and entity types listed on the SAP API Business Hub. Similar to the code snippet above, you can access not only read operations but also write operations (Function Import is not yet supported).

Straightforward integration of SAP Cloud Platform

The above code snippet also illustrates out-of-the-box integration with the Destination Service on the SAP Cloud Platform for managing target systems or target and authentication credentials. Don’t worry if you don’t see it at first sight – due to direct integration, it’s easy to miss: When Execute is called on an OData VDM request, you pass the name of the target, which in this case is S4Hanacloud. That being said, the SDK is responsible for resolving the target defined in the target service on the SAP Cloud Platform and performing the required authentication.

You can also define the destination manually if you prefer. In addition, during a local run or test, the target service can easily be replaced with simple environment variables.

TypeScript or JavaScript?

The above example uses TypeScript, which is a typed superset of JavaScript. However, if you’re only familiar with JavaScript, you might not even notice. In fact, the above code is perfectly valid JavaScript. The SAP Cloud SDK for JavaScript is implemented in TypeScript and can be used in JavaScript and TypeScript projects. Both JavaScript and TypeScript developers can use the same libraries and get the same functionality, and both benefit from TypeScript-enabled code completion in the context of supporting editors. TypeScript projects certainly benefit from the extra type safety.

We can only encourage everyone to check whether TypeScript fits their needs. If you don’t want to use TypeScript, it’s still perfectly fine to stick to pure JavaScript and use the SDK in JavaScript.

Continuous delivery pipeline

The Continuous Delivery Toolkit is a core component of the SAP Cloud SDK because it enables projects to continuously deliver their applications without additional work to set up the Continuous Delivery Pipeline. We were pleased to be able to provide this out-of-the-box continuous delivery pipeline for JavaScript projects right from the start.

To do this, we provide two project scaffolding, one for TypeScript and one for JavaScript projects. Out of the box, they include everything you need to run a continuous delivery pipeline on a Jenkins server. You don’t have to write a line of pipeline code to benefit from the best practices that are codified in the pipeline, just configure it into your project environment. For more details on what is supported, see the release announcement for the Continuous Delivery Toolkit version V17.

How to Access the JavaScript Libraries

The JavaScript library for the SAP Cloud SDK is freely accessible from SAP’s NPM registry. The SAP registry works similar to the standard NPMJS registry used to parse JavaScript modules. It hosts packages with a scope of @SAP. To be able to retrieve the SDK modules (all of which are supplied with the @SAP scope), you simply execute the following command:

npm config set “@sap:registry” “https://npm.sap.com”

Then, select any module of the SDK listed in the module overview in the documentation and install it as a dependency in your Node.js project, for example:

npm install @sap/cloud-sdk-vdm-business-partner-service