Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member184995
Active Contributor
0 Kudos

The code for working with Webi and Deski documents is essentially identical and alot of the same code is used when working with both objects, this includes things such as exporting.

One of the areas where they diverge is when you try and export an individual report from a document that contains more than one report.

For example, you have a webi document that contains 3 webi reports.  The code to export the 2nd report to pdf is as follows:

********************************************

IDocumentInstance boIDocumentInstance = boIReportEngine.OpenDocument(boInfoObjects[1].ID);
boIDocumentInstance.Refresh();

//Caste it to a IReport object and set the PaginationMode, this is mandatory
IReport rep = boIDocumentInstance.Reports[1];

//Export and stream to pdf
IBinaryView boIBinaryView = (IBinaryView)rep.GetView(OutputFormatType.Pdf);

Response.ContentType = "application/pdf";
Response.AddHeader("Content-disposition", "inline;filename=document.pdf");
boIBinaryView.WriteContent(Response.OutputStream);

********************************************

When trying to use this same code with a deski document you will get the error:

"The requested supported view is invalid.  Parameter: PDF"  which seems to make little sense since it says right there in the error that the view that is being requested is supported, but not valid...Ok..

So to accomplish the same with a deski document you have to manipulate the reports paginationmode.  By default the mode is Page which will not allow the export.  This needs to be changed to Listing to allow the export.

The code is just:

********************************************

IDocumentInstance boIDocumentInstance = boIReportEngine.OpenDocument(boInfoObjects[1].ID);
boIDocumentInstance.Refresh();

//Caste it to a IReport object and set the PaginationMode, this is mandatory
IReport rep = boIDocumentInstance.Reports[1];

//Added for Deski documents
rep.PaginationMode = PaginationMode.Listing;

//Export and stream to pdf
IBinaryView boIBinaryView = (IBinaryView)rep.GetView(OutputFormatType.Pdf);

Response.ContentType = "application/pdf";
Response.AddHeader("Content-disposition", "inline;filename=document.pdf");
boIBinaryView.WriteContent(Response.OutputStream);

********************************************

I hope this helps as I did not find anything documented on this and this simple line of code can save alot of headaches 🙂