Skip to Content
avatar image
Former Member

Display pdf retrieved using odata service in iframe

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

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

    Resolved by using new odata service.

    Add comment
    10|10000 characters needed 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-

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

    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

    Add comment
    10|10000 characters needed characters exceeded