Skip to Content

How to call a Media File(PDF) in odata service (OModel.read) form backend to frontend in sapui5

I have been working on the SAPUI5 and I try to get a PDF File from backend when we test it in the SAP Gateway Client "EntitySet()/$value" it's working

~status_code 200

~status_reason OK

but in button press function the oModel.read code gives an error.

Cannot read property 'body' of undefined

My button code :

function() {

var value = this.getView().byId("inputValue").getValue();

var sRead = "/PrintProcessSet(Tknum='" + value + "')/$value";

var html = new sap.ui.core.HTML();

var oModel = this.getView().getModel();

oModel.read(sRead, {

success: function(oData, oResponse) {

var response = oResponse.requestUri;

html.setContent("<iframe src=" + response + " width='700' height='700'></iframe>");

var windows = window.open("", "My PDF", " width='700' height='700'");

windows.document.write(html);

windows.print();

windows.close();

},

error: function() {

alert("Read failed");

}

});

},

We get the Following error

Failed to load resource: the server responded with a status of 404 (Not Found) jquery.sap.global-dbg.js:

1022 2017-10-11 11:41:58.602000 [extended_runnable_file.html] The following problem occurred: no handler for data - O @ jquery.sap.global-dbg.js:1022 Q.fatal @ jquery.sap.global-dbg.js:1066 r._handleError @ VM63:2741 r._processError @ VM63:2734 v @ VM63:2726 w @ VM63:2726 v @ VM63:2723 (anonymous) @ VM63:2790 (anonymous) @ datajs.js:17 p9 @ datajs.js:17 datajs.js:17

Uncaught TypeError: Cannot read property 'body' of undefined

at constructor.r._createEventInfo (eval at evalModuleStr (jquery.sap.global-dbg.js:3406), <anonymous>:2683:1013)

at constructor.r._processSuccess (eval at evalModuleStr (jquery.sap.global-dbg.js:3406), <anonymous>:2733:1605)

at w (eval at evalModuleStr (jquery.sap.global-dbg.js:3406), <anonymous>:2726:831)

at v (eval at evalModuleStr (jquery.sap.global-dbg.js:3406), <anonymous>:2723:122)

at eval (eval at evalModuleStr (jquery.sap.global-dbg.js:3406), <anonymous>:2790:272)

at eval (datajs.js:17) at XMLHttpRequest.p9 (datajs.js:17)

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Oct 11, 2017 at 07:38 AM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 12, 2017 at 08:39 AM

    are you able to solve this issue?

    regards

    Manik Saluja

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 20 at 07:24 AM

    Hi,

    I'm having the same issues. Does this resolved?

    Regards,

    Ben

    Add comment
    10|10000 characters needed characters exceeded