cancel
Showing results for 
Search instead for 
Did you mean: 

Batch in ODATA for PUT returns 'Error while parsing an XML stream' - 'CX_SXML_PARSE_ERROR' - SAPUI5

0 Kudos

Hi Guys,

I'm trying to send a table from my frontend to backend via ODATA call. I'm using batch processing and the code is as below.

var sPath = "emp_tabSet(Objid='121')";
changeOperations.push(oModel.createBatchOperation(sPath,"PUT",dataT[0],null));
oModel.addBatchChangeOperations(changeOperations);
oModel.submitBatch(function(oData, oResponse, aErrorResponses){
if(aErrorResponses.length>0){
sap.m.MessageBox.alert("Error in Creating. Please try again...");
console.log(aErrorResponses);
}else{
sap.m.MessageBox.alert("Batch Successfull", {});
}
});

I have also redefined the methods /IWBEP/IF_MGW_CORE_SRV_RUNTIME~CHANGESET_BEGIN and /IWBEP/IF_MGW_CORE_SRV_RUNTIME~CHANGESET_END in the backend.

I tried executing a GET request from my gateway system and it worked fine. When I tried to execute a PUT, which is actually what I need, just see a popup that says empty response received. In the browser I have 'Error while parsing an XML stream' after all the batch submissions. I tried researching the SCN forums and found that it maybe an issue with the payload but I couldn't figure out what. Here's my payload that I got from chrome.

--batch_6763-24d6-b1aa Content-Type: multipart/mixed; boundary=changeset_ee32-82a7-97f4

--changeset_ee32-82a7-97f4 Content-Type: application/http Content-Transfer-Encoding: binary

PUT emp_tabSet(Objid='121') HTTP/1.1 Accept-Language: EN Accept: application/atom+xml,application/atomsvc+xml,application/xml MaxDataServiceVersion: 2.0 DataServiceVersion: 2.0 Content-Type: application/atom+xml Content-Length: 1648

<a:entry xmlns:a="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"><a:author><a:name/></a:author><a:id>http:/sap/opu/odata/sap/ZHS_VALIDARE_SRV/emp_tabSet(ObjKey='000000',Objid='55007881',Req='')</a:id><a:category term="ZHS_VALIDARE_SRV.emp_tab" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/><a:content type="application/xml"><m:properties><d:ObjKey m:type="Edm.String">000000</d:ObjKey><d:Objid m:type="Edm.String">55007881</d:Objid><d:Stext m:type="Edm.String">Dl VASILE TOMARIU</d:Stext><d:TmvEePos m:type="Edm.String">Sef uel etansare a</d:TmvEePos><d:TmvEeOrgun m:type="Edm.String">RENAULT GROUP</d:TmvEeOrgun><d:TmvEeWerks m:type="Edm.String">Uzina Vehicule Dacia</d:TmvEeWerks><d:TmvEeBtrtl m:type="Edm.String">Plate-forme ind</d:TmvEeBtrtl><d:ObjSel m:type="Edm.String">X</d:ObjSel><d:Status m:type="Edm.String"/><d:Mtvhs m:type="Edm.String">0002</d:Mtvhs><d:Versl m:type="Edm.String">3</d:Versl><d:MtvhsText m:type="Edm.String">Fabricatie Piese schimb si CKD</d:MtvhsText><d:BeginTime m:type="Edm.String">18:00</d:BeginTime><d:EndTime m:type="Edm.String">19:00</d:EndTime><d:Stdaz m:type="Edm.String">1.00</d:Stdaz><d:StdazCumul m:type="Edm.String">0.00</d:StdazCumul><d:TmvEePersk m:type="Edm.String"/><d:Ipn m:type="Edm.String"/><d:Req m:type="Edm.String"/><d:Acord m:type="Edm.String"/><d:AfisareVersl m:type="Edm.String"/><d:DataAcord m:type="Edm.String" m:null="true"/><d:OraAcord m:type="Edm.String">PT00H00M00S</d:OraAcord></m:properties></a:content></a:entry> --changeset_ee32-82a7-97f4--

--batch_6763-24d6-b1aa--

Can someone please point me in the right direction? Your help is highly valued and appreciated.

Thanks in advance

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

So the ideal complete payload is as below.

--batch_d8ed-3aca-caf0
Content-Type: multipart/mixed; boundary=changeset_4dca-23ed-f026

--changeset_4dca-23ed-f026
Content-Type: application/http
Content-Transfer-Encoding: binary

PUT emp_tabSet(Objid='121') HTTP/1.1
Accept-Language: EN
Accept: application/atom+xml,application/atomsvc+xml,application/xml
MaxDataServiceVersion: 2.0
DataServiceVersion: 2.0
Content-Type: application/atom+xml
Content-Length: 1619

<a:entry xmlns:a="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">
   <a:author>
      <a:name />
   </a:author>
   <a:id>/sap/opu/odata/sap/ZHS_VALIDARE_SRV/emp_tabSet('12345678')</a:id>
   <a:category term="ZHS_VALIDARE_SRV.emp_tab" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
   <a:content type="application/xml">
      <m:properties>
         <d:ObjKey m:type="Edm.String">000000</d:ObjKey>
         <d:Objid m:type="Edm.String">12345678</d:Objid>
         <d:Stext m:type="Edm.String">Dl VXXXX YYYYY</d:Stext>
         <d:TmvEePos m:type="Edm.String">Sef uel etansare a</d:TmvEePos>
         <d:TmvEeOrgun m:type="Edm.String">XXXX GROUP</d:TmvEeOrgun>
         <d:TmvEeWerks m:type="Edm.String">Uzina RRRR XXXX</d:TmvEeWerks>
         <d:TmvEeBtrtl m:type="Edm.String">Plate-forme ind</d:TmvEeBtrtl>
         <d:ObjSel m:type="Edm.String">X</d:ObjSel>
         <d:Status m:type="Edm.String" />
         <d:Mtvhs m:type="Edm.String">0002</d:Mtvhs>
         <d:Versl m:type="Edm.String">3</d:Versl>
         <d:MtvhsText m:type="Edm.String">Fabricatie XXXX XXXX YYYY CKD</d:MtvhsText>
         <d:BeginTime m:type="Edm.String">18:00</d:BeginTime>
         <d:EndTime m:type="Edm.String">19:00</d:EndTime>
         <d:Stdaz m:type="Edm.String">1.00</d:Stdaz>
         <d:StdazCumul m:type="Edm.String">0.00</d:StdazCumul>
         <d:TmvEePersk m:type="Edm.String" />
         <d:Ipn m:type="Edm.String" />
         <d:Req m:type="Edm.String" />
         <d:Acord m:type="Edm.String" />
         <d:AfisareVersl m:type="Edm.String" />
         <d:DataAcord m:type="Edm.String" m:null="true" />
         <d:OraAcord m:type="Edm.String">PT00H00M00S</d:OraAcord>
      </m:properties>
   </a:content>
</a:entry>
--changeset_4dca-23ed-f026--

--batch_d8ed-3aca-caf0--
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Arun,

the payload that you posted looks like as it does not have the right format. But this might be due to the Editor in the SCN Q&A section.

I suggest you post it again as Code.

The following update request sent via $batch:

https://<host>:<port>/sap/opu/odata/IWBEP/TEA_TEST_APPLICATION/$batch

is taken from the CORE_SAMPLES provided with the SAP Gateway Client.

--batch

Content-Type: multipart/mixed; boundary=changeset



--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary



PUT Conversions(Id='1') HTTP/1.1

Content-Type: application/json



{

    "Id" : "1",

    "price_1" : "-299.99",

    "currency_1" : "EUR",

    "price_2" : "1.706",

    "currency_2" : "KWD",

    "amount_1" : "1.1235",

    "unit_1" : "D",

    "amount_2" : "1.123",

    "unit_2" : "CMS",

    "oSQL_Where_Cl" : "",

    "Is_Boolean" : true

}



--changeset--



--batch--

Shows more line breaks and empty lines than the payload you have provided above.

When manipulating the payload I get however the following (different) error message than you:

"The Data Services Request could not be understood due to malformed Syntax"

Regards,

Andre

0 Kudos

Hi Andre,

Thanks for your response. The payload I posted was taken from the browser. That's why it looks unformatted. I've formatted the XML in that payload and it looks like below. Please let me know if you need something else that could help in solving this.

<a:entry xmlns:a="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">
   <a:author>
      <a:name />
   </a:author>
   <a:id>/sap/opu/odata/sap/ZHS_VALIDARE_SRV/emp_tabSet('12345678')</a:id>
   <a:category term="ZHS_VALIDARE_SRV.emp_tab" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
   <a:content type="application/xml">
      <m:properties>
         <d:ObjKey m:type="Edm.String">000000</d:ObjKey>
         <d:Objid m:type="Edm.String">12345678</d:Objid>
         <d:Stext m:type="Edm.String">Dl VXXXX YYYYY</d:Stext>
         <d:TmvEePos m:type="Edm.String">Sef uel etansare a</d:TmvEePos>
         <d:TmvEeOrgun m:type="Edm.String">XXXX GROUP</d:TmvEeOrgun>
         <d:TmvEeWerks m:type="Edm.String">Uzina RRRR XXXX</d:TmvEeWerks>
         <d:TmvEeBtrtl m:type="Edm.String">Plate-forme ind</d:TmvEeBtrtl>
         <d:ObjSel m:type="Edm.String">X</d:ObjSel>
         <d:Status m:type="Edm.String" />
         <d:Mtvhs m:type="Edm.String">0002</d:Mtvhs>
         <d:Versl m:type="Edm.String">3</d:Versl>
         <d:MtvhsText m:type="Edm.String">Fabricatie XXXX XXXX YYYY CKD</d:MtvhsText>
         <d:BeginTime m:type="Edm.String">18:00</d:BeginTime>
         <d:EndTime m:type="Edm.String">19:00</d:EndTime>
         <d:Stdaz m:type="Edm.String">1.00</d:Stdaz>
         <d:StdazCumul m:type="Edm.String">0.00</d:StdazCumul>
         <d:TmvEePersk m:type="Edm.String" />
         <d:Ipn m:type="Edm.String" />
         <d:Req m:type="Edm.String" />
         <d:Acord m:type="Edm.String" />
         <d:AfisareVersl m:type="Edm.String" />
         <d:DataAcord m:type="Edm.String" m:null="true" />
         <d:OraAcord m:type="Edm.String">PT00H00M00S</d:OraAcord>
      </m:properties>
   </a:content>
</a:entry>