Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Hi Friends,

In this document I am trying to show case of $batch operation on Gateway services with multiple operations on multiple entitysets in a single call.

1.  Introduction

The OData batch concept is used to send the data of several requests in a single HTTP request from the client to the SAP Net Weaver Gateway server.  In real time scenario it will increases the mobile offline capabilities as well.

This document covers the following Batch operations.

            1. Batch operation on READ
            2. Batch operation on QUERY
            3. Batch operation on READ and QUERY with multiple entity set
            4. Batch operation on POST
            5. Batch operation on POST with multiple entity set
            6. Batch operation on PUT
            7. Batch operation on PUT with multiple entity set
            8. Batch operation on READ, QUERY, POST and PUT on multiple entity set


2. Batch operation Formation

2.1  Batch Request:

        • The body of a batch request is made up of an ordered series of retrieve operations and change sets.
        • A change set is an atomic unit of work that is made up of an unordered group of one or more of the insert, update or delete operations.
        • Change sets cannot contain retrieve requests and cannot be nested, i.e a change set cannot contain a change set

       2.2 Set the header name:


                   Set the content-type as show in the screen shot. Name the batch name in the boundary (here I used batch_123)

Setting the Line Gaps in the request payload:         

        1. There should be min 2 lines of gap between content type and batch.
        2. GET operation should have one line up and two lines down gap.
        3. Batch should be closed.
        4. Batch can be implemented on POST operation only
        5. If you are using changeset means it should close

          The Sample URI which i am using for this project      URI: /sap/opu/odata/sap/ZBATCH_PUT_SRV/$batch


                                               Sample request.                                     

3. Batch operation on READ


    Execute the URI then you will get the successful status 202. Your response body will execute the query with

   the status code 200.


4. Batch operation on Query


                                                 



5. Batch operation on READ and QUERY with multiple entity set

Here I am executing the batch operation with different Entity sets ( GET_SAVESEARCHSet and SET_SAVESEARCHSet )


6. Batch operation on POST

For the POST,PUT,PATCH and DELETE operations we have to use the changeset tag.


Sample payload.

          --batch_1234

          Content-Type: multipart/mixed; boundary=changeset_01234

          --changeset_01234

          Content-Type: application/http

          Content-Transfer-Encoding: binary

          POST SET_SAVESEARCHSet HTTP/1.1

          Content-Type: application/atom+xml

          Content-Length: 9999

          <Payload Body>

          --changeset_01234--

          --batch_1234--

7. Batch operation on POST with multiple entity set

Here I am using the two entity sets and  posting the data at a time.
Sample payload.



--batch_123

             Content-Type: multipart/mixed; boundary=changeset_1234

           --changeset_1234

           Content-Type: application/http

           Content-Transfer-Encoding: binary

           POST SET_SAVESEARCHSet HTTP/1.1

           Content-Type: application/atom+xml

           Content-Length: 9999

          <Payload Body1>

          --changeset_1234

          Content-Type: application/http

          Content-Transfer-Encoding: binary

          POST GET_SAVESEARCHSet HTTP/1.1

          Content-Type: application/atom+xml

          Content-Length: 9999

          <Payload Body2>

        --changeset_1234--

        --batch_123--

  8. Batch operation on PUT

             Now i am going to implement the PUT opearation.

sample payload


          --batch_123

          Content-Type: multipart/mixed; boundary=changeset_1234

          --changeset_1234

          Content-Type: application/http

          Content-Transfer-Encoding: binary

          PUT GET_SAVESEARCHSet(Reempid='0000000250',Rdistr='1100') HTTP/1.1

          Content-Type: application/atom+xml

          Content-Length: 9999

          <Payload Body>

          --changeset_1234--

          --batch_123--


9. Batch operation on PUT with multiple entity set

                Here I am doing PUT operation on two different entity sets.

       sample payload


          --batch_123

          Content-Type: multipart/mixed; boundary=changeset_1234

          --changeset_1234

          Content-Type: application/http

          Content-Transfer-Encoding: binary

          PUT GET_SAVESEARCHSet(Reempid='0000000250',Rdistr='1100') HTTP/1.1

          Content-Type: application/atom+xml

          Content-Length: 9999

          <Payload Body1>

          --changeset_1234

          Content-Type: application/http

          Content-Transfer-Encoding: binary

          PUT SET_SAVESEARCHSet(Reempid='0000000250',Rdistr='1100') HTTP/1.1

          Content-Type: application/atom+xml

          Content-Length: 9999

          <Payload Body2>

          --changeset_1234--

          --batch_123--

10. Batch operation on READ, QUERY, POST and PUT on multiple entity sets

Now I am going to implement all the operations (READ, QUERY, POST, and PUT) on multiple entity sets in a single call.

Note: Here PUT and POST operations all together come under Changeset begin and Changeset close

(i.e.  --changeset   …..< Body>  …  --changeset--)

    For sample payload Refer attachment file Batch_Multi


So Try it Happy Learning



Regards

Kiran Adhikarla

7 Comments
Labels in this area