Skip to Content

Introduction

SAP Cloud Platform Integration provides support to create and host/provision your OData services via the creation of OData Service artifacts. You can find more information about OData Service creation in the documentation https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/d961654cd36b46ad83b668e4434c9f04.html.

This blog explanations on how to invoke the provisioned service in $batch mode and excludes the details on how to create an OData Service.

OData Service

There is no extra configuration or implementation required in OData Service projects to enable $batch mode invocation. As of now the $batch works with below scope/restriction

  1. Only one operation is support per changeset
  2. The Message Processing Log (MPL) per changeset is generated

An OData Service as shown in the below example will be used for the explanation. This OData Service is internally designed to invoke another OData service.

Below is the integration flow generated for Query operation of ProuctSet of OData Service. The integration flow editor opens upon clicking on icon under the Action column against the operation.

 

Upon successful deployment of this OData Service, the endpoint is generated and hosted. The hosted endpoint information is available under the Monitoring -> Overview -> Manage Integration Content as shown in below screenshot. Copy and use this endpoint where it is needed to be invoked.

 

Invoking OData Service

In this example, let’s invoke this OData service in a REST client application, POSTMAN. You need to append /$batch at the end of OData Service URL, e.g. in our case it will be https://<tenant-host>/gw/odata/SAP/ODATA_SERVICE_BATCH_DEMO;v=1/$batch. You need to first fetch the csrf token and use it in the HTPP POST request.

Below is the POST request payload content

--batch_123
Content-Type: application/http
Content-Transfer-Encoding: binary

GET ProductSet(3) HTTP/1.1


--batch_123
Content-Type: multipart/mixed; boundary=changeset_1

--changeset_1
Content-Type: application/http
Content-Transfer-Encoding: binary

POST ProductSet HTTP/1.1
Content-Type: application/json

{
 "ID": 55,
 "Name": "Example55",
 "Rating": 9,
 "Price": "9.9",
 "ReleaseDate": "2008-05-08T00:00:00"
}

--changeset_1--
--batch_123--

Below is the sample screenshot of POSTMAN client

Headers section

Body section

Response body section

 

Example response body contents are as below.

--batch_416e1927-4e84-4ef7-b81f-df9349fe1323
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 200 OK
Location: https://pmt2pw5-iflmap.hcisb.int.sap.hana.ondemand.com:443/gw/odata/SAP/ODATA_SERVICE_BATCH_DEMO;v=1/ProductSet(3)
Content-Type: application/atom+xml;charset=utf-8;type=entry
Cache-Control: no-store, no-cache
Content-Length: 1027

<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://pmt2pw5-iflmap.hcisb.int.sap.hana.ondemand.com:443/gw/odata/SAP/ODATA_SERVICE_BATCH_DEMO;v=1/"><id>https://pmt2pw5-iflmap.hcisb.int.sap.hana.ondemand.com:443/gw/odata/SAP/ODATA_SERVICE_BATCH_DEMO;v=1/ProductSet(3)</id><title type="text">ProductSet</title><updated>2018-11-21T05:54:38.35Z</updated><category term="S1.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"></category><link href="ProductSet(3)" rel="edit" title="Product"></link><content type="application/xml"><m:properties><d:ID>3</d:ID><d:Name m:null="true"></d:Name><d:Description m:null="true"></d:Description><d:ReleaseDate>2005-10-01T00:00:00</d:ReleaseDate><d:DiscontinuedDate>2006-10-01T00:00:00</d:DiscontinuedDate><d:Rating>3</d:Rating><d:Price>19.9</d:Price></m:properties></content></entry>
--batch_416e1927-4e84-4ef7-b81f-df9349fe1323
Content-Type: multipart/mixed; boundary=changeset_591ce50b-9727-46bf-8881-0fd7cac16dd3

--changeset_591ce50b-9727-46bf-8881-0fd7cac16dd3
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 201 Created
Location: https://pmt2pw5-iflmap.hcisb.int.sap.hana.ondemand.com:443/gw/odata/SAP/ODATA_SERVICE_BATCH_DEMO;v=1/ProductSet(55)
Content-Type: application/atom+xml;charset=utf-8;type=entry
Content-Length: 997

<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://pmt2pw5-iflmap.hcisb.int.sap.hana.ondemand.com:443/gw/odata/SAP/ODATA_SERVICE_BATCH_DEMO;v=1/"><id>https://pmt2pw5-iflmap.hcisb.int.sap.hana.ondemand.com:443/gw/odata/SAP/ODATA_SERVICE_BATCH_DEMO;v=1/ProductSet(55)</id><title type="text">ProductSet</title><updated>2018-11-21T05:54:38.351Z</updated><category term="S1.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"></category><link href="ProductSet(55)" rel="edit" title="Product"></link><content type="application/xml"><m:properties><d:ID>55</d:ID><d:Name></d:Name><d:Description></d:Description><d:ReleaseDate>2008-05-08T00:00:00</d:ReleaseDate><d:DiscontinuedDate m:null="true"></d:DiscontinuedDate><d:Rating>9</d:Rating><d:Price>9.9</d:Price></m:properties></content></entry>
--changeset_591ce50b-9727-46bf-8881-0fd7cac16dd3--
--batch_416e1927-4e84-4ef7-b81f-df9349fe1323--

 

Message Processing Log

As mentioned in the above section on scope/restrictions, an MPL per changeset is created. In the example above, we are using two changeset requests, one for GET and other for POST, hence there will be two MPLs generated for the sample scenario.

 

Summary

The invocation of SAP Cloud Platform Integration OData Service can be done in $batch mode with mentioned scope/restrictions.

 

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply