cancel
Showing results for 
Search instead for 
Did you mean: 

$Batch with Odata

hussain_p
Participant
0 Kudos

Hi Experts,

When I am using batch am getting the success resposnse(202) for all oprations( read , post , put)but iam not getting response body as well as no entries are created  in table level by Post method.

i have followed below steps.

1) Redifined Changeset_begin , changeset_end methods.

Requst Header :

Request Header:

Content-Type    multipart/mixed;boundary=batch

X-CSRF-Token   n5eBImWR4NnoK7aOIP1hKA==

Request body:

--batch
Content-Type: multipart/mixed;boundary=changeset


--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary


POST headerSet HTTP/1.1
Content-Type: application/atom+xml
Content-Length:
1400



<?xml version=
"1.0" encoding="utf-8"?>
<entry xml:base=
"http://ITFS1.hq.company.com:8000/sap/opu/odata/sap/ZTEST_DEEP_INSERT1_SRV/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<id>http://ITFS1.hq.company.com:8000/sap/opu/odata/sap/ZTEST_DEEP_INSERT1_SRV/headerSet(
'23')</id>
<title type=
"text">headerSet('23')</title>
<updated>2015-05-25T10:05:47Z</updated>
<category term=
"ZTEST_DEEP_INSERT1_SRV.header" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href=
"headerSet('23')" rel="self" title="header"/>
<link href=
"headerSet('23')/itemSet" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/itemSet" type="application/atom+xml;type=feed" title="itemSet"/>
<content type=
"application/xml">
<m:properties>
<d:Id>987</d:Id>
<d:Name>BATCH</d:Name>
</m:properties>
</content>
</entry>
--changeset--
--batch--

URL : /sap/opu/odata/sap/ZTEST_DEEP_INSERT1_SRV/$batch

click on enter :

no entry created with the id 987.

Break-points are also not trigerred in Changeset_begin , changeset_end methods.

Please help me to to solve the issue.

Thanks in Advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Hussain,

For now just redefine the ChangeSet_End and Begin Methods and write 'EXIT' statement and activate the class. Do not write any code.

Payload should have correct spacing. Use the below Payload and check ->

--batch
Content-Type: multipart/mixed;boundary=changeset

--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary

POST headerSet HTTP/1.1
Content-Type: application/atom+xml
Content-Length:
1400

<?xml version=
"1.0" encoding="utf-8"?>
<entry xml:base=
"http://ITFS1.hq.company.com:8000/sap/opu/odata/sap/ZTEST_DEEP_INSERT1_SRV/"xmlns="http://www.w3.org/2005/Atom"xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<id>http://ITFS1.hq.company.com:8000/sap/opu/odata/sap/ZTEST_DEEP_INSERT1_SRV/headerSet(
'23')</id>
<title type=
"text">headerSet('23')</title>
<updated>2015-05-25T10:05:47Z</updated>
<category term=
"ZTEST_DEEP_INSERT1_SRV.header"scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href=
"headerSet('23')" rel="self" title="header"/>
<link href=
"headerSet('23')/itemSet"rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/itemSet"type="application/atom+xml;type=feed" title="itemSet"/>
<content type=
"application/xml">
<m:properties>
<d:Id>987</d:Id>
<d:Name>BATCH</d:Name>
</m:properties>
</content>
</entry>



--changeset--
--batch--


Below will help ->



Regards,

Ashwin

hussain_p
Participant
0 Kudos

Thanks Ashwin for quick reply

i have followed above instructions still iam getting 202 response and  errors in response body .

--D9F229F70009A726D195F276271C776B0

Content-Type: application/http

Content-Length: 849

content-transfer-encoding: binary

HTTP/1.1 400 Bad Request

Content-Type: application/xml

Content-Length: 744

dataserviceversion: 1.0

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

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

<code>CX_ST_MATCH_ELEMENT/544FAE4641562346A1372144E7396586</code>

<message xml:lang="en">System expected the element '{http://www.w3.org/2005/Atom}entry'</message>

<innererror>

<transactionid>589603E5B054F11180CB12829B923AF1</transactionid>

<timestamp>20150526120519.9770000</timestamp>

<Error_Resolution>

<SAP_Transaction>Run transaction /IWFND/ERROR_LOG on SAP NW Gateway hub system and search for entries with the timestamp above for more details</SAP_Transaction>

<SAP_Note>See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)</SAP_Note>

</Error_Resolution>

<errordetails/>

</innererror>

</error>

--D9F229F70009A726D195F276271C776B0--

AshwinDutt
Active Contributor
0 Kudos

In the payload change the Content-Type as ' application/xml ' and check please.

Former Member
0 Kudos

Hi Ashwin,

From Ui ,i am trying to do a mass data creation.If i am trying to create 10 item and out of which one of the item fails,i want to have a response back saying ,which all were sucessful and which resulted in error.How this can be achieved .I tried sending each create in separate changeset and even in case of error ,i get individual response.Is this the correct approch,to send ecah create in a separate changeset?Could you please help me here.

Thanks and Regards

Neeta

AshwinDutt
Active Contributor
0 Kudos

Hello Neeta,

Please check the section ' Handling Operations in Batch Requests ' and try this approach ->

Call the Data Provider Class in Defer Mode :

$batch Processing - SAP NetWeaver Gateway - SAP Library

This way you can perform Create operation for all 10 items in one go and capture the success/error messages as part of GW response.

Regards,

Ashwin

Former Member
0 Kudos

Hi Ashwin,

Thanks a lot for the link.Its really helpful.

Could you please let me know how to call a batch in defer mode?ie If i have test in in ethe gateway_client a sample request ,how to set the defer mode so that change_process method gets triggered.

Thanks and Regards

Neeta

AshwinDutt
Active Contributor
0 Kudos

Hello Neeta,

I do not have a working example to show but i can share the DPC name which has a demo case implemented for this approach.

Please have a look at the below class -> This has all details and helps you to implement

Class - /IWBEP/CL_MGW_RT_SFLIGHT

Methods -

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_BEGIN

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_END

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_PROCESS

Regards,

Ashwin

Former Member
0 Kudos

Hi Ashwin ,

Thanksfor your quick response .What i am looking for is the request xml ,which will identify a batch request as deferred.Normally when i send a batch request ,it will not trigger the change set_process.So if this method needs to be triggered, what change should i make in the response xml?

Thanks and Regards

Neeta

AshwinDutt
Active Contributor
0 Kudos

Hello Neeta,

As far as i know there nothing to be added in the request payload for this. Payload would remain same if DPC is called in defer mode or not in defer mode.

Regards,

Ashwin