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.
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.
2.1 Batch Request:
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:
The Sample URI which i am using for this project URI: /sap/opu/odata/sap/ZBATCH_PUT_SRV/$batch
Sample request.
Execute the URI then you will get the successful status 202. Your response body will execute the query with
the status code 200.
Here I am executing the batch operation with different Entity sets ( GET_SAVESEARCHSet and SET_SAVESEARCHSet )
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--
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--
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |