Skip to Content

How to do Batch Request in HCI OData Adaptor

Everyone knows what is OData protocol – It is for accessing diverse data in a common way. With OData adaptor in HCI you can connect any OData service provider and perform the required integration scenario.

In this blog I am explaining how to do a batch request with multiple operations on different OData collections.

If you are new to OData adaptor read this blog: OData Adapter in SAP HANA Cloud Integration

An OData batch request allows you to execute multiple operations in a single HTTP request.


Let’s take an example.

  • Assume that you have two OData collections – Products and SalesOrders.
  • You should be able to do a batch with multiple operations as given below.

     /wp-content/uploads/2016/03/2016_03_23_10_34_51_914011.jpg


  • But, if you are using OData adaptor, you will find that you don’t have an option to choose multiple OData collections as given below.

     /wp-content/uploads/2016/03/2016_03_23_10_23_48_914009.jpg

     /wp-content/uploads/2016/03/2016_03_23_10_24_25_914010.jpg

  • It doesn’t mean that HCI is not stopping you from doing a batch request with multiple operations on different OData collections.
  • The solution is to send the batch request in the payload irrespective of what you configured in the model operation.
  • To show you how it works I have created a simple iFlow. (I am not going to the basics of creating an iflow, if you are new to HCI read this blog)

     /wp-content/uploads/2016/03/2016_03_23_10_39_06_914018.jpg

  • I have two OData collections – Products, SalesOrders.
  • In my batch request I want to create a Product and a SalesOrder.

     /wp-content/uploads/2016/03/2016_03_23_13_19_49_914174.jpg

  • Hence the equivalent batch request payload to be used in HCI content modifier body is given below.

     /wp-content/uploads/2016/03/2016_03_23_13_33_07_914175.jpg

  • For your reference the I have attached the body used in the postman rest client, download it here.
  • The format of the batch request body to be used is given below. It will be same from all OData services.

     /wp-content/uploads/2016/03/2016_03_24_08_36_06_914856.jpg

  • The details for the payload could be taken from the metadata of OData service.
  • Given below I have highlighted entitySetName and entityTypeName in my metadata.

     /wp-content/uploads/2016/03/2016_03_23_13_44_01_914198.jpg

  • If your backend is an on premise system (ex. SAP Gateway) you need to configure HANA Cloud Connector with your HCI as mentioned in this blog.
  • In the adaptor settings the address should be referring to your virtual host and port configured in HCC. And the Proxy Type should be On-Premise.
  • Choose a model operation with batch processing enabled. The Odata collection chosen could be independent of the batch payload we are using.

    /wp-content/uploads/2016/03/2016_03_23_13_57_33_914199.jpg

  • Now we could deploy the project and see how the two create operations (create product and create salesorder) worked through a batch request.

     /wp-content/uploads/2016/03/2016_03_22_20_19_02_914252.jpg

Regards, Midhun

SAP Technology RIG

4 Comments
You must be Logged on to comment or reply to a post.
  • Hi Midhun

    Is the XML schema for the batch request standard for all OData service or specific to this example Gateway service?

    If we were to use this in a real-life scenario, and the actual payload is generated via Mapping, can the Operation Modeler generate a corresponding XSD file with the appropriate “batch” nodes based on the EDMX definition?

    Regards

    Eng Swee

    • Hello Eng Swee,

      In my experience, I haven’t seen any other OData service which support batch request.

      So I would say its specific to OData g/w service till I find other OData service.

      For your second question, yes, Operation modeler generates the nodes.

      reg, avinash

    • Hi Eng,

      • The batch payload format is the same for all odata services.
      • I haven’t tried with a mapping, but I believe that it should work too.

      Regards, Midhun

      SAP Technology RIG

  • Hi Midhun

    Thanks for your blog,

    I’ve a same requirement where 2 entity need to post by using batch operation.

    With a help of message mapping i need to post Invoice and InvoiceItemDeatils to Odata. and Enabled batch Processing as TRUE by using model operator.

    as i flowed your blog, by using below payload i posted successfully to Odata.

    <?xml version="1.0" encoding="UTF-8"?>
    <batchParts>
    	<batchChangeSet>
    		<batchChangeSetPart>
    			<method>POST</method>
    			<Invoices>
    				<Invoice>
    					<VendorNo>4716001571</VendorNo>
    					<VendorName>Roeld</VendorName>
    					<StatusID>01</StatusID>
    					<StatusDesc>Received</StatusDesc>
    					<InvoiceNo>R201</InvoiceNo>
    					<InvoiceDate>2016-10-31T07:13:31</InvoiceDate>
    					<InvoiceAmt>-144309.00</InvoiceAmt>
    					<Currency>INR</Currency>
    					<BuyerName> Technologies Private Limited</BuyerName>
    				</Invoice>
    			</Invoices>
    		</batchChangeSetPart>
    	</batchChangeSet>
    	<batchChangeSet>
    		<batchChangeSetPart>
    			<method>POST</method>
    			<InvoiceItemDetails>
    				<InvoiceItemDetail>
    					<UOM/>
    					<StatusID>01</StatusID>
    					<StatusDesc>Received</StatusDesc>
    					<Quantity>1</Quantity>
    					<MaterialDesc/>
    					<MaterialCode/>
    					<ItemNo>0001</ItemNo>
    					<InvoiceNo>R20</InvoiceNo>
    				</InvoiceItemDetail>
    			</InvoiceItemDetails>
    		</batchChangeSetPart>
    	</batchChangeSet>
    	<batchChangeSet>
    		<batchChangeSetPart>
    			<method>POST</method>
    			<Invoices>
    				<Invoice>
    					<VendorNo>4716001571</VendorNo>
    					<VendorName>Roield</VendorName>
    					<StatusID>01</StatusID>
    					<StatusDesc>Received</StatusDesc>
    					<InvoiceNo>R202</InvoiceNo>
    					<InvoiceDate>2016-10-31T07:13:31</InvoiceDate>
    					<InvoiceAmt>-144309.00</InvoiceAmt>
    					<Currency>INR</Currency>
    					<BuyerName> Technologies Private Limited</BuyerName>
    				</Invoice>
    			</Invoices>
    		</batchChangeSetPart>
    	</batchChangeSet>
    	<batchChangeSet>
    		<batchChangeSetPart>
    			<method>POST</method>
    			<InvoiceItemDetails>
    				<InvoiceItemDetail>
    					<UOM/>
    					<StatusID>01</StatusID>
    					<StatusDesc>Received</StatusDesc>
    					<Quantity>1</Quantity>
    					<MaterialDesc/>
    					<MaterialCode/>
    					<ItemNo>0001</ItemNo>
    					<InvoiceNo>R20</InvoiceNo>
    				</InvoiceItemDetail>
    			</InvoiceItemDetails>
    		</batchChangeSetPart>
    	</batchChangeSet>
    </batchParts>

    bu the issue is,whereas the extracted XSD doesn’t contains the InvoiceItemDetails.

    how can  we get the  XSD from Odata which contains Invoice and InvoiceItemDeatils entity details?

    please suggest

    Regards

    Ramesh