Skip to Content
0

Display pdf retrieved using odata service in iframe

Apr 03, 2017 at 05:10 AM

404

avatar image
Former Member

Hello experts,

I have created a sapui5 application using Web IDE for retreiving a .pdf file using odata and displaying it in an iframe.

I have followed the initial steps (not the improved steps) as mentioned in the following blog :

https://blogs.sap.com/2014/02/03/display-smartform-pdf-in-sapui5/

The application runs well when i create a tile and execute from my launchpad, but when I click on the button for opening the pdf file, it executes the success function, but does not display anything in the iframe.

Kindly suggest.

Thanks in advance,

Jalpa Desai

10 |10000 characters needed characters left characters exceeded

can you check if any error is recorded in the console and please share the code that you are using to show the pdf.

Best Regards,
Mahesh

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member Jul 28, 2017 at 09:52 AM
0

Resolved by using new odata service.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi,

I'm having the same issues as yours and have changed my odata service to V2.

var oModel = new sap.ui.model.odata.v2.ODataModel("serviceUrl", true);

But I'm getting error "Cannot read property 'body' of undefined" when reading the oData service.

Any inputs?

Thanks.

Regards,

-Ben-

0
avatar image
Former Member Apr 04, 2017 at 06:24 AM
0

Hello experts,

I have written the code in button click as follows. But doest not get anyting when I click the button. (Iframe is empty)

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

var uri="/sap/opu/odata/sap/Zservice_srv";

var oModel=new sap.ui.model.odata.ODataModel(uri,false);

sap.ui.getCore().setModel(oModel);

var sRead = "/***Set/('1234')";

oModel.read(sRead,null,null,false, function(oData,oResp){

pdfurl=oData.url;

html.setContent("<iframe src='"+pdfurl+"'/>");

sap.m.MessageToast.show("success");

},function(){

sap.m.MessageToast.show("Error");

});

this.getView().byId.addContent(html);

Kindly Advise.

Jalpa Desai

Share
10 |10000 characters needed characters left characters exceeded