Welcome to Summer, dear SAP Cloud SDK customers! With COVID-19 numbers hopefully plummeting while the heat is clearly going up, another nicely growing number is your Google searches leading to the SAP Cloud SDK documentation portal. It helped us reach a new milestone with more than 5K clicks in May. Thanks a lot for your trust and for keeping the SDK your tool of choice.

To match the positive momentum we worked hard in May delivering new exciting features and supporting our library of pre-generated clients up to date.
Invitation to the Community Call on June'23
Sign-up:
Click here to sign up. Looking forward to seeing you there. The link to the recording will be published in our
documentation portal afterward.
Topic:
Easy consumption of OpenAPI services using OpenAPI Client Generator of SAP Cloud SDK for JavaScript
Speaker:
Marika Marszalkowski - Lead SDK Developer
Introduction:
There are hundreds of OpenAPI services published on
SAP Business Hub. To consume these services in your cloud applications you would make use of connectivity services and write a lot of boilerplate code in addition to your business logic.
The SAP Cloud SDK provides the means to generate type-safe clients for OpenAPI services (in Java, Javascript, or Typescript) so that you can focus on developing the core business functionality of your application.
In this session, you will learn how to conveniently consume OpenAPI services on SAP BTP using the SAP Cloud SDK for JavaScript. You will also learn how to offer and configure your services as a pre-generated client specifically for your service in case you are a service owner.
Libraries for the latest SAP S/4HANA releases
Both
Java and
JavaScript SDK have released pre-generated client libraries for the latest
Cloud and On-premise version of the SAP S/4HANA. Check them out in package repositories.
Mind, some services like
C_TRIALBALANCE_CDS introduce breaking changes which are also reflected in the SDK type-safe client.
Quick links
SAP Cloud SDK for Java 3.46.0
Support for OData V4 Functions and Actions
The OData v4 standard allows
functions and actions to be defined on both services and specific entities. Those defined on a service are called
unbound
while entity-related ones called
bound
. We've supported unbound functions and actions already for some time. Let's remind how the
unbound
OData function call looks like.
service.myFunction("paramValue1", "paramValue2")
.execute(destination);
Now SDK also supports
bound
functions and actions. For bound operations, you have to provide an entity and the API looks like this.
service.forEntity(person)
.applyFunction(Person.isHappy());
You can also call a function on a collection of entities.
service.applyFunction(Person.AreAllHappy());
Some functions may be defined as
composable. We support this as well. It means you can leverage the results of an OData function call and apply an operation on top of it. The example below illustrates that.
service.forEntity(person)
.withFunction(Person.getBestFriend())
.navigateTo(Person.FRIENDS)
.getAll();
To acquire an entity to run a
bound operation on, you can either pre-fetch it via the
getByKey
call similar to:
service.getBusinessPartnerByKey("id");
Then the SDK will handle some complexity like ETag for you. If you're aware of what parameters you have to pass you can also use a builder on an entity to construct a call yourself.
BusinessPartner businessPartnerById = BusinessPartner.builder().businessPartner("123").build();
Find more information and examples on the API for OData functions and actions
here.
Long-awaited IN
operator in OData Filters
OData V4 standard introduced more filtering operations including
IN
which is now supported by the type-safe API. It behaves similar to the
IN
operator in SQL
GetAllRequestBuilder<Person> request;
// Age in (40,41,42)
request.filter(Person.AGE.in(40,41,42));
// BestFriend in Friends
query.filter(Person.TO_BEST_FRIEND.in( Person.TO_FRIENDS ) );
For advanced use-cases like building a query string yourself, you can use our generic OData client to build compliant filtering expressions with
IN
operator.
StructuredQuery query;
// Age in (40,41,42)
query.filter(FieldReference.of("Age").in( 40,41,42 ));
// BestFriend in Friends
query.filter(FieldReference.of("BestFriend").in( FieldReference.of("Friends").asCollection()) );
// 'Green' in Colors
query.filter(ValueString.literal("Green").in( FieldReference.of("Colors").asCollection()) );
Support for OData V2 Function Calls in BATCH
You can now leverage OData V2 function calls via BATCH changesets like this:
service.batch()
.beginChangeSet()
.addFunctionImport(service.callSomeFunction())
.endChangeSet()
.executeRequest(destination);
Type-safe Client Library for BTP Business Rules Service
To complement the already released
SAP Workflow service, the SAP Cloud SDK has released a new module
btp-business-rules
that represents the
SAP Business Rules service. It's another client library base on the OpenAPI specification and certified by the SAP Cloud SDK for Java.
Now you can do Business Rules
Authoring and
Execution in just a few lines of code like this
// Business Rules Authoring
// requires dependency com.sap.cloud.sdk.services:btp-business-rules
HttpDestination authoringDestination =
ScpCfServiceDestinationLoader
.getDestinationForService(
ScpCfServiceDestinationLoader.CfServices.BUSINESS_RULES_AUTHORING,
"my-business-rules");
ProjectsApi projectsApi = new ProjectsApi(authoringDestination);
List<ProjectVersionObject> allProjects = projectsApi.readProjects();
// Business Rules Execution
// requires dependency com.sap.cloud.sdk.services:btp-business-rules
HttpDestination executionDestination =
ScpCfServiceDestinationLoader
.getDestinationForService(
ScpCfServiceDestinationLoader.CfServices.BUSINESS_RULES_EXECUTION,
"my-business-rules");
DeployUndeployRuleServiceApi deployService = new DeployUndeployRuleServiceApi(executionDestination);
List<WorkingsetRuleServiceDefinitionResult> deployedWorkingSets = deployService.readWorkingsetRuleServices();
Johannes Schneider published an
extensive guide on consuming the Business Rules service with the SAP Cloud SDK in our documentation portal. Check it out and send us your feedback!
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
Certified SAP Workflow Type-safe Client Now Also for JavaScript
For more than half a year a certified client for SAP Workflow service was available for the Java SDK but not for JavaScript. Well, we have great news for you! Just run a code snippet below to get an officially certified type-safe client for SAP Workflow service in JavaScript!
$ npm install @sap/cloud-sdk-workflow-service-cf
The client is released to NPM and updated regularly to match frequent releases of the SAP Workflow service. It means you don't have to bother with regenerating it from its OpenAPI specification anymore. To make the resulting API more semantic our generator leverages OpenAPI extension to aid Classes and Methods naming.
Mind, we only support the SAP Workflow service on the BTP Cloud Foundry environment. You can't use the type-safe Client in BTP Neo as it's not recommended for new porjects.
To give you a sneak peek at how the API looks like, let's retrieve a task of the SAP Workflow service.
import { UserTaskInstancesApi } from '@sap/cloud-sdk-workflow-service-cf';
async function getTask(
workflowInstance: WorkflowInstance
): Promise<TaskInstance> {
const [taskInstance] = await UserTaskInstancesApi.queryInstances({
workflowInstanceId: workflowInstance.id
}).execute(destination);
return taskInstance;
}
Looks neat, doesn't it? For more examples and code snippets check our
detailed guide by Marika Marszalkowski and let us know what you think.
Need More Type-safe OpenAPI Client Libraries by the SDK?
We continue to refine our
tailor-made OpenAPI code generator to make sure you can get a convenient type-safe client for any valid specification you can find on the
SAP API Business Hub. Give it a try with your favorite service on the SAP Business Technology platform and see how your development shifts towards handling business logic instead of navigation quirks of HTTP requests and coding best practices.
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