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: 
arunchembra1
Participant

This blog contains information regarding batch concept in SAP NetWeaver Gateway Consumers . The OData Batch requests allow the grouping of multiple operations into a single HTTP request payload. I have seen lot of discussion regarding the  batch concept.

This is a brief blog to explain how to implement batch in SAP system and how to make batch gateway service calls for READ,CREATE and UPDATE.

In SAP we don't have to write any additional logic to implement batch, just have to redefine/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_BEGIN and/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_END methods as shown below.

READ :

Example of executing a batch request containing multiple Read operations.

URL:

http://**************/sap/opu/odata/sap/<Main_Service_Name>/$batch

HEADER:

Authorization: SAP ID & PASSWORD

x-csrf-token:   Enter Token

Content-Type: multipart/mixed; boundary=batch

BODY:

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

Accept: application/xml

GET ABCCollection/?$filter= EMP_ID eq '10000030' HTTP/1.1

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

Accept: application/jsonxml

GET ABCCollection/?$filter=EMP_ID eq '10000031' HTTP/1.1

  --batch--

CREATE:

Example of executing a batch request containing multiple Create operations.

URL:


http://**************/sap/opu/odata/sap/<Main_Service_Name>/$batch

HEADER :

Authorization: SAP ID & PASSWORD

x-csrf-token:   Enter Token

Content-Type: multipart/mixed; boundary=batch

    

BODY:

--batch

Content-Type: multipart/mixed; boundary=changeset

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

POST ABCCollection HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 588

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"

xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"

xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<atom:content type="application/xml">

<m:properties>

<d:EMP_ID>10000033</d:EMP_ID>

<d:FIRST_NAME>MIKE</d:FIRST_NAME>

<d:LAST_NAME>JOHNSON</d:LAST_NAME>

</m:properties>

</atom:content>

</atom:entry>

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

POST ABCCollection HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 588

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"

xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"

xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<atom:content type="application/xml">

<m:properties>

<d:EMP_ID>10000034</d:EMP_ID>

<d:FIRST_NAME>ALLAN</d:FIRST_NAME>

<d:LAST_NAME>XAVIER</d:LAST_NAME>

</m:properties>

</atom:content>

</atom:entry>

--changeset--

--batch--

UPDATE:

Example of executing a batch request containing multiple Update operations(Change names).

URL:


http://**************/sap/opu/odata/sap/<Main_Service_Name>/$batch

HEADER :

Authorization: SAP ID & PASSWORD

x-csrf-token:   Enter Token

Content-Type: multipart/mixed; boundary=batch

    

BODY:

--batch

Content-Type: multipart/mixed; boundary=changeset

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

PUT ABCCollection('10000033') HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 588

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"

xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"

xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<atom:content type="application/xml">

<m:properties>

<d:EMP_ID>10000033</d:EMP_ID>

<d:FIRST_NAME>MIKE_CHANGE</d:FIRST_NAME>

<d:LAST_NAME>JOHNSON_CHANGE</d:LAST_NAME>

</m:properties>

</atom:content>

</atom:entry>

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

PUT ABCCollection('10000034') HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 588

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"

xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"

xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<atom:content type="application/xml">

<m:properties>

<d:EMP_ID>10000034</d:EMP_ID>

<d:FIRST_NAME>ALLAN_CHANGE</d:FIRST_NAME>

<d:LAST_NAME>XAVIER_CHANGE</d:LAST_NAME>

</m:properties>

</atom:content>

</atom:entry>

--changeset--

--batch--

Reference Links:

http://help.sap.com/saphelp_gateway20sp06/helpdata/en/90/dc8363306c47d3b2fca1398f5de94b/content.htm

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40546820-3ea7-2f10-dfab-be373c0da...

30 Comments
Labels in this area