Hi,

My name is Sunny, I am part of SAP Cloud Platform Integration (CPI) – Customer Success Team.

As a member of Customer Success Team, we are responsible for enabling/support customers and internal stakeholders to achieve their integration scenarios using SAP Cloud Platform Integration tool.

During the support, we encounter some tricky scenarios, which are not very specific to their use case but can be common to all.

This blog is an answer to one of such tricky question i.e.

How can I make OData Batch Request with multiple operations on multiple entity sets.

Customer need this capability majorly for the following use cases:

  1. Customer wants to pack several functionally related API requests and send them to the web API service in one HTTP request and receive a single HTTP response with the response to all their requests. For example: Update in one entity set, also requires an upate in another functionally related entity set.
  2. Customer want to  pack several API requests and send them to the web API service in one HTTP request and receive a single HTTP response by creating their own OData service on CPI platform. This new OData service then call existing OData service with mutiple operations on multiple entity sets using single batch request.This way, the client can optimize calls to the server and improve the scalability of its service.

 

OData Adapter in SAP Cloud Platform Integration supports batch operation. To know more about the batch operation in OData adapter, kindly read the existing blog on OData Adapter.

As per the OData specification https://www.odata.org/documentation/odata-version-2-0/batch-processing/, a single batch request can contain multiple operations on multiple entity sets but the design time of OData adapter in CPI supports creation of a batch request with single operation on single entity set.

Nevertheless from a runtime perspective, the runtime of OData adapter in SAP Cloud Platform Integration supports execution of a batch request with multiple operations on multiple entity sets.

Now the question is, if the runtime supports, then how we can achieve the same in CPI web tooling with its current set of capabilities. By the end of this blog, this question will be answered.

 

Example Scenario:

Consider a scenario in which we are getting a single payload, with data of multiple entity sets.

Using this single payload we make an OData batch request with multiple operations on multiple entity sets.

 

For this scenario, we are using the OData Demo V2 service

https://services.odata.org/V2/(S(wqb5nkyghvr4elijgf5vvb1f))/OData/OData.svc

This OData service is having three entity sets i.e. Products, Categories and Suppliers. We will make a single batch call with POST on Categories, PUT on Suppliers and MERGE on Products.

 

Integration Flow

 

The above integration flow is explained below:

  1. Configure the Timer to Run Once
  2. In Content Modifier, hardcode the initial payload in the body as given below:
       3 NewCategoryName     1 ChangedSupplierName 
    Whitefield Bangalore Karnataka 560066 INDIA
    2 4 24

    This single payload contains the data for all three entity sets i.e. Products, Categories and Suppliers.

  3. Then use Parallel Multicast(as order doesn’t matter in this scenario), with three branches to get the batch request compliant payload for each entity set and operation

  4. In each branch we use Message Mapping with initial payload XSD as the source and XSD of each batch operation as the target to get the batch request compliant payload for each entity set and operation

    Initial Payload XSD

                                                                 

    Hint: To get the XSD of each batch operation along with the entity set and it’s properties, configure OData Adapter one by one for:

    a. POST on Categories,

    b. PUT on Suppliers, and

    c. MERGE on Products

    This will generate three batch operation compliant XSD files i.e. CategoriesEntityPOST0.xsd, SuppliersEntityPUT0.xsd and ProductsEntityMERGE0.xsd

  5. Now Join all the three branches followed by the Gather step to get the single batch request payload
  6. This will generate the cumulative batch request payload with single batchChangeSet for all the three operations as given below:
       POST   3 NewCategoryName     PUT  
    If-Match W/"0"
    1 ChangedSupplierName
    Whitefield Bangalore Karnataka 560066 INDIA
    MERGE 2 4 24
  7. Then call the OData endpoint using OData Adapter using Request-Reply flow step.

    Important Note: The OData Adapter can be configured with any batch operation. In design time selecting a particular entity set and batch operation doesn’t matter as the call will happen based on the previous cumulative batch request payload.

  8. Finally the OData batch request response is captured as an XML file in SFTP Server
         1.0;  no-cache  204   No Content   

This way we can make a single batch request with multiple operations on multiple entity sets.

 

With the learnings of this blog, I recommend you to try this capability in OData Provisoning (ODP) i.e. create a new OData service from existing OData service and internally make a batch request with muiltiple operations on multiple entity sets.

New NetWeaver Information at SAP.com

Very Helpfull

User Rating: Be the first one !