Skip to Content
Technical Articles
Author's profile photo Merina Acharya

Batch processing with ODataV4 Adapter in SAP CPI

SAP CPI offers OData adapter to communicate with OData services. It supports messages with JSON as well as Atom format. The message protocol in CPI can be either OData V2 or OData V4. You can use either OData V2 or OData V4 depending on the OData service you need to communicate with.  More details on the difference between V2 and V4 is available at – https://help.sap.com/doc/saphelp_uiaddon20/2.05/en-US/ab/d4d7c7548d4c29ab8364d3904a6d74/frameset.htm

This blogs explains the procedure to process batch processing (using operation POST ) in OData V4 service receiver OData Adapter.

Configure the adapter as per the instruction – https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/cd66a12cc2054e36a5dfa6b93d56c7bb.html

In OData V2, batch processing can be enabled using the below option:

However with OData V4 this option is not available. In order to process the request SAP has provided the below operations:

In order to send batch data the Operation ‘Batch Processing ($batch)’ needs to be selected.

 After selecting the operation, add either a ‘Changeset’ or a ‘Batchset’. I have added ‘Batchset’ and selected the entity ‘Logs’ for this scenario:

This will generate an EDMX file, the structure of the payload looks like this:

The field <method> denotes the operation to be performed, in this scenario we will be using ‘POST’. Provide the entity name in the field <uri>,  in this case it will be ‘Logs’.

The remaining fields can be mapped as per your requirement. It is mandatory to have at least one ‘batchSet1’ in a batch request payload. Note that structure should looks something like this after the mapping:

Deploy the iflow and trigger a message, this would post all the records in a single call.

 

Assigned tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Christopher Linke
      Christopher Linke

      Hi @Merina Achary

      great article, thank you!

      I have two questions:

      • Is that possible with OData V2 as well?
      • How do I know if the service supports V2 oder V4? e.g. all the objects of the api.sap.com page, like:
        • https://api.sap.com/api/API_PRODUCT_SRV/overview
      Author's profile photo si-chan Ham
      si-chan Ham

      I am trying to follow this but I am getting error. My Iflow is as follows.

       

      My content modifier body has payload like below.

      <batchParts>
      <batchChangeSet1>
      <batchChangeSetPart1>
      <method>POST</method>
      <uri>Categories</uri>
      <body>
      <Categories>
      <Category>
      <ID>956</ID>
      <Name>Laptops</Name>
      </Category>
      </Categories>
      </body>
      </batchChangeSetPart1>
      </batchChangeSet1>
      </batchParts>

      I am using Batch operation

       

      I am not getting what is the issue.But its not working I am getting error as

      java.lang.IllegalArgumentException: Invalid content type

       

      Can you help me here

      Author's profile photo Mastan Vali
      Mastan Vali

      Hi Marina,

      Can you provide the OData URL you are using or sample one to achieve this scenario.

      Regards,

      Mastan