Hi All,
This blog is continuation ofSimple Step-by-Step SAP-Gateway Service Guide ,
In above mentioned blog you'll find all structures,tables,entities,entity sets,association and all basic operations(CRUD), Once you done with basic operations, When the requirement is as follows.. you can continue with this blog
Again this is for beginners,not for experts
In some cases, business entity instances may logically belong together and need to be handled or processed together in the same logical unit of work. For example, on a sales order, an update of two or more related item entries could be required and must be processed together in a single request (all or none).
SAP Net Weaver Gateway can be used to process such scenarios with its capability to execute multiple operations in a single request.
Starting with SP 04, SAP Net Weaver Gateway provides the capability for client applications to batch multiple operations into a single HTTP request, allowing for a series of retrieve operations and/or modifying operations to be executed using one request.
O Data Batch requests allow the grouping of multiple operations into a single HTTP request payload. The components of a batch request, how the request is handled, and the components of the batch response have some significant differences from components and processing of a normal, single-operation OData request.
Batch Requests are submitted as a single HTTP POST request to the batch endpoint of a service.
Initial (Mandate) Steps :
1. Go to transaction SEGW.
2.Expand Project(which we created in above mentioned blog) -> Run time Artifacts.
3.Right click on class ends with DPS_EXT.
4. Select Go to ABAP Workbench.
5. Go to edit mode.
6. Redefine methods.
a. /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_BEGIN.
b. /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_END.
Steps:
a. Click on /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_BEGIN and click redefine button.
b. Click on /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_END and click redefine button.
Only redefine and comment the code inside.
7.Activate the service.
8. Go to gateway client .(Please referSimple Step-by-Step SAP-Gateway Service Guide).
---------------------------------------------------------------------------------------------------------
Batch Read :
Steps:-
1. Check HTTP Method as POST.
2. Request URI -> Append /$batch at the end of the service name.
------------/sap/ZEMPLOYEE_INFO_SRV/$batch
3. Click on Add Header.
4. Enter Content-Type as
multipart/mixed; boundary=batch
5. Paste the code in http request body.
--batch Content-Type: application/http Content-Transfer-Encoding: binary GET EmpDetailsSet('76')?$format=xml HTTP/1.1 --batch Content-Type: application/http Content-Transfer-Encoding: binary GET EmpDetailsSet('77')?$format=xml HTTP/1.1 --batch—
6. Replace Entity Set and Values according to yours.
7. Click Execute.
You’ll get two records in HTTP Response body.
---------------------------------------------------------------------------------------------------------
Batch Create :
Steps :-
Follow steps 1- 4 of Batch Read.
1. Paste the code in http request body.
--batch Content-Type: multipart/mixed; boundary=changeset --changeset Content-Type: application/http Content-Transfer-Encoding: binary POST EmpDetailsSet 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:DETAILS m:type="ZEMPLOYEE_INFO_SRV.Details"><d:Street1>Pai Layout</d:Street1><d:Street2>Bangalore</d:Street2><d:City>BANGALORE</d:City><d:Country>INDIA</d:Country></d:DETAILS><d:EMP_ID>76</d:EMP_ID><d:NAME>ARSHAD SHAIKH CREATE</d:NAME><d:ADDRESS>BANGALORE</d:ADDRESS><d:SALARY>100000000</d:SALARY></m:properties></atom:content></atom:entry> --changeset Content-Type: application/http Content-Transfer-Encoding: binary POST EmpDetailsSet 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:DETAILS m:type="ZEMPLOYEE_INFO_SRV.Details"><d:Street1>Pai Layout</d:Street1><d:Street2>KR Puram</d:Street2><d:City>BANGALORE</d:City><d:Country>INDIA</d:Country></d:DETAILS><d:EMP_ID>77</d:EMP_ID><d:NAME>LK SONI CREATE</d:NAME><d:ADDRESS>BANGALORE</d:ADDRESS><d:SALARY>100000000</d:SALARY></m:properties></atom:content></atom:entry> --changeset-- --batch—
6. Click Execute.
Your No of records maintained in above request body will be created.
---------------------------------------------------------------------------------------------------------
Batch Update :
Steps:-
Follow steps 1- 4 of Batch Read.
5 . Paste the code in http request body.
--batch Content-Type: multipart/mixed; boundary=changeset --changeset Content-Type: application/http Content-Transfer-Encoding: binary PUT EmpDetailsSet('76') 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:DETAILS m:type="ZEMPLOYEE_INFO_SRV.Details"><d:Street1>Pai Layout</d:Street1><d:Street2>Bangalore</d:Street2><d:City>BANGALORE</d:City><d:Country>INDIA</d:Country></d:DETAILS><d:EMP_ID>76</d:EMP_ID><d:NAME>ARSHAD SHAIKH UPDATE</d:NAME><d:ADDRESS>BANGALORE</d:ADDRESS><d:SALARY>100000000</d:SALARY></m:properties></atom:content></atom:entry> --changeset Content-Type: application/http Content-Transfer-Encoding: binary PUT EmpDetailsSet('77') 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:DETAILS m:type="ZEMPLOYEE_INFO_SRV.Details"><d:Street1>Pai Layout</d:Street1><d:Street2>KR Puram</d:Street2><d:City>BANGALORE</d:City><d:Country>INDIA</d:Country></d:DETAILS><d:EMP_ID>77</d:EMP_ID><d:NAME>LK SONI UPDATE</d:NAME><d:ADDRESS>BANGALORE</d:ADDRESS><d:SALARY>100000000</d:SALARY></m:properties></atom:content></atom:entry> --changeset-- --batch—
6. Click Execute.
Your No of records maintained in above request body will be updated.
---------------------------------------------------------------------------------------------------------
Batch Delete :
Steps:-
Follow steps 1- 4 of Batch Read.
5 .Paste the code in http request body.
--batch Content-Type: multipart/mixed; boundary=changeset --changeset Content-Type: application/http Content-Transfer-Encoding: binary DELETE EmpDetailsSet('76') HTTP/1.1 --changeset Content-Type: application/http Content-Transfer-Encoding: binary DELETE EmpDetailsSet('77') HTTP/1.1 --changeset-- --batch—
6.Click Execute.
Your No of records maintained in above request body will be Deleted.
Thanks,
Arshad Shaikh --