cancel
Showing results for 
Search instead for 
Did you mean: 

V2 OData Model - Get_Stream Call in Batch Operation

former_member1321
Participant
0 Kudos

HI All,

I want to call the get_stream method of an Odata Model in SAPUI5 in a batch operation. I am able to call it via window.open("//url//") way but the issue is that I do not want to directly call the URL.

My requirement is to first call a Get_Entityset method to generate an xstring value which can later be retrieved via Get_Stream method. The xstring basically refers to an excel file.

I am doing it like:

var oModel = oController.getView().getModel("mainModel");
			oModel.setDeferredGroups(["ReadExcel"]);
			var mParameters = {
				groupId: "ReadExcel",
				success: function (odata, resp) {
					//	window.open(resp.requestUri);
					//	window.open("/destinations/XXX/sap/opu/odata/sap/ZXXXX_SRV/FileSet(Mandt='101',Filename='test_file')/$value");
				},
				error: function (odata, resp) {}
			};


			oModel.read("/DummySet", {
				groupId: "ReadExcel",
				filters: [new sap.ui.model.Filter({
					path: "RepName",
					operator: sap.ui.model.FilterOperator.EQ,
					value1: oController.getView().byId("idRepName").getValue().toUpperCase()
				})]
			});


			oModel.read("/FileSet(Mandt='101',Filename='test_file')/$value", {
				groupId: "ReadExcel"
			});


			//Submit Batch
			oModel.submitChanges(mParameters);

I am able to receive the xstring data as I see in network tab

HTTP/1.1 200 OK
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Content-Length: 12610
sap-metadata-last-modified: Wed, 03 Jun 2020 01:47:07 GMT
cache-control: no-store, no-cache
x-content-type-options: nosniff
content-disposition: inline; filename=main.xlsx
dataserviceversion: 2.0

......
PKÐ<ÏPE6cdocProps/core.xmlm‘ÍnÂ0„_Åò˜P©ª¢D=	‰VíÕØKp‰´^yû:M#ÁͳóíHë)WWÛ°`4Þ-yžÍ9§¼6®^òϏ·Ùg«ªT¡Pa‹>’ÈÒž‹…
K~$
…QÁʘ%Â%óàÑJJk¤:ÉÄb>HjIRô³0&rvËÔjÌgl†­4`ÁQy–‹	L€6>Üœ)j
u²æ?~f$Û¶ÍÚ§M7äâ{ó¾ΝI:¼*µ*ÈPLïxÞÿ€¢›R’<V»õ–}Á~½+ÅdÚÿï	ºÖ£Ž·
Q¡	”zé'	hd¤Mjæ`@¿vÓ¤{³ç.¦¯µÊb”C™’ öØõÑâ®ÜêPKÐ<ÏPKrÛa´-docProps/app.xmlÍ‚0„_¥é
Œ1¥ÄD½™xPï¤,кM»|{«ÄŸ³{۝Ù/3²šÇMàƒA[ò<Í8«±1¶+ùå|HÖœUJž<:ðd °ø`CÉ{"·"èÆ:¤Q¶Qiя5ÅÕwÛÖhØ¡¾`IY¶0ØšÄ}€œ-ÈÍDÿRÔÏ€áz¾»TrëÜ`tM±”:í1`Kl?k¤øŸÎëÒ^åEšÅyÞ7)¾ÍÕPKÐ<ÏP!7M#Í[xl/workbook.xmlÁnƒ0DÅÚ¨!Jªáœr(çHÉÙÅK¼
ö"ÛôïcH9ö63–ßÌÖ#‡ÇóCL®÷QMi¨¤Œ­E§ãèóKÇÁé”m¸Ë8Ô&ZÄäz¹+ŠOé4yxªðwµxæöסO/HÀ^'b-
......

but I also get the following error in console:

Log-dbg.js:456 2020-06-15 16:00:38.229250 The following problem occurred: no handler for data -  
datajs.js?eval:17 Uncaught TypeError: Cannot read property 'body' of undefined
    at constructor.I._createEventInfo (ODataModel-dbg.js:1226)
    at constructor.I._processSuccess (ODataModel-dbg.js:3924)
    at W (ODataModel-dbg.js:3283)
    at V (ODataModel-dbg.js:3009)
    at ODataModel-dbg.js:6142
    at eval (datajs.js?eval:17)
    at XMLHttpRequest.p9 (datajs.js?eval:17)

and the control doesn't go inside the success function.

Please provide your inputs/thoughts regarding this issue or any work-around so achieve the same.

former_member1321
Participant
0 Kudos

karan.bahl1987, saurabh.vakil, himanshupensia, nitin.kant

any thoughts on this??

View Entire Topic
karanbahl
Active Participant
0 Kudos

Hi Deepak,

Can you please share at what step are you getting the error?

Can you check whether the x-string length is causing the issues?

Regards,

Karan