How to run a webi document and export the result to PDF, Excel etc using BO Java Report Engine SDK

This post describes the typical code required to run a Webi document and export the result to PDF, Excel, CSV or XML file. Here is the compete code .

The workflow is the following

  1. Open a webi document
  2. Run queries
  3. Set prompts and contexts
  4. Export
  5. Close

The important is that the queries should be run before setting the prompts.

Open a Webi document

Let’s assume that we found an Id of  Webi document.

DocumentInstance doc = reportEngine.openDocument(infoObject.getID());

Run queries

The queries can be run using DocumentInstance.refresh() or DataProviders.runQueries().

doc.refresh();

Prepare answers to prompts

It is convenient to create a map that for each prompt provides a set of values, and later use this map to enter the prompts.

HashMap<String, String[]> answers = new HashMap<String, String[]>();
answers.put("Country:", new String[]{"US", "France"});
answers.put("Year:", new String[]{"FY2004"});

(Here we assume that the document has two prompts “Country:” and “Year:”.)

Enter the prompts values

For each prompt, the code looks up the values in the map, enters the values using Prompt.enterValues().

After that, it sets the prompts using DocumentInstance.setPrompts(). At this point, if all mandatory prompts are set, the document is be refreshed.

Note that you can get name of the report in two ways. Prompt.getID() return original name and Prompt.getName() returns localized name (if there are translations for the document).

Prompts prompts = doc.getPrompts();
for (int i = 0; i < prompts.getCount(); i++) {
    Prompt prompt = prompts.getItem(i);
    String[] answer = answers.get(prompt.getID());
    if (answer != null) {        
        prompt.enterValues(answer);
    }
}
doc.setPrompts();

Check if the document has been refreshed

If there are mandatory prompts that are not answered, setPrompts() will not refresh document. If so we print error message.

if (doc.getMustFillPrompts()) {
    System.out.println("ERROR: Mandatory prompts has not been entered");
}

Also it is possible that there are multiple contexts and one need to be selected in order to run the document. In most cases the documents are designed to avoid prompting about contexts, so here we assume that there is no need to select one. But just in case, we check this also.

if (doc.getMustFillContexts()) {
    System.out.println("ERROR: Context has not been selected");
}

Export to PDF

We can export complete document, a report of the document, or data providers.

For instance to export the document to PDF, we can get view in the PDF format and write the contents to a file.

BinaryView binaryView2 = (BinaryView)doc.getView(OutputFormatType.PDF); 
String title = infoObject.getTitle();
writeBytes(binaryView2.getContent(), title + ".pdf");

Here we use an auxiliary function that writes byte array to a file.

public static void writeBytes(byte[] data, String filename) throws IOException {
    File file = new File(filename); 
    FileOutputStream fstream = new FileOutputStream(file); 
    fstream.write(data); 
    fstream.close();
}

Export to Excel

We can export the document to an Excel file using similar code:

BinaryView xlsView = (BinaryView)doc.getView(OutputFormatType.XLS);
writeBytes(xlsView.getContent(), title + ".xls");

There are two types of Excel output format type, OutputFormatType.XLS is optimized for presentation and OutputFormatType.XLSDataCentric is optimized for data manipulation.

Export to CSV

We can export data from one or all data providers to a CSV file:

CSVView csvView = (CSVView)doc.getDataProviders().getView(OutputFormatType.CSV);
writeBytes(csvView.getContent().getBytes(), title + ".csv");

BinaryView.getContent() returns content as byte array, while CSVView.getContent() returns String. Therefore we use String.getBytes() to adhere the function writeBytes().

Export to HTML

It is also possible to export each report of the document individually for instance to a HTML files. In this case you need to change pagination mode to listing otherwise you can get partial result.

Reports reports = doc.getReports();
for (int i = 0; i < reports.getCount(); i++)
{
    Report report = reports.getItem(i);
    report.setPaginationMode(PaginationMode.Listing);
    HTMLView htmlView = (HTMLView) report.getView(OutputFormatType.DHTML);
    writeBytes(htmlView.getContent().getBytes(), title + " " + i + ".html");
}

Done

That is it.

doc.closeDocument();

122 thoughts on “How to run a webi document and export the result to PDF, Excel etc using BO Java Report Engine SDK

      1. RAGHU

        Hi Sindhu,

        We need to write this in Eclipse or any IDE after adding jars of BO4.0.

        Please check how to do this in SDK category of this webpage. Dmytro explained it very clearly .

        Regards,
        Raghu

        Like

      2. Vadivel

        Hi Dmytro,

        I am trying to export report instances in WEBI format to PDF format.

        I use the same code as yours

        BinaryView binaryView2 = (BinaryView)doc.getView(OutputFormatType.PDF);
        String title = infoObject.getTitle();
        writeBytes(binaryView2.getContent(), title + “.pdf”);

        If the number of pages in the report instance are around 2000 pages , This code works.

        But we have reports with close to 9900 pages.I do not see any error message or break, But no output is seen.

        Is there anyway to fix this issue?

        Thanks in Advance for your suggestion.

        Vadi

        Like

      3. dmytro Post author

        Hi Vadi
        I assume you hit the limit for Maximum Character Stream Size for Web Intelligence Processing Server which is 5MB by default. Try to increase it.
        It is strange that you do not get any error message. It cannot probably fail silently. Check that your catch block is not empty but prints exception message.
        Typical error message is “Maximum character output size limit reached (Error: ERR_WIS_30272)”
        (Do you print those huge documents?:))

        Like

    1. mfmayv@ETFC

      I am using the latest release of BI 4.1 SDK and need to download webi report instance to disk so that I can programatically restore these webi document instances to another BI server. Is there a way to download documents in a raw byte[] stream to then save to disk or push to another BI server?

      Like

      Reply
  1. RAGHU

    Hi,

    Thanks for the quick response. It’s working for 4.0. I will try it on 3.1 today. I am trying to add a line to get the execution time of each report in the output. If Possible could you please help me to add the execution time of each report.

    Thanks & Regards,
    Praveen

    Like

    Reply
    1. dmytro Post author

      Hi Praveen

      Before doc.setPrompts(), add

      Date start = new Date();

      After doc.setPrompts(), add

      Date end = new Date();
      double timespan = (end.getTime() - start.getTime()) / 1000.;		
      System.println("Execution time: " + timespan + " seconds");
      

      Like

      Reply
  2. JC Martin

    Your codes have been very helpful and I appreciate you sharing them.

    I don’t mean to be picky, but just wanted to let you know that one of the sections you say Export to XML instead of Excel.

    Thanks a lot. Your code is really helping me to hit the ground running!

    Like

    Reply
    1. dmytro Post author

      In the example, the exported files are saved to the current folder.

      You can specify folder when writing file e.g.

      writeBytes(xlsView.getContent(), "C:\\Docs\\" + title + ".xls");
      

      Like

      Reply
  3. Syed

    Hi ,

    How to implement this code onto BO server? I want users when they export webi reports to excel- a default string to be saved along with it inside the excel.

    Like

    Reply
  4. François

    Hello

    thanks for this useful example. Could you publish the list of jars you use to run this program ?

    Here we can execute it, we have an error on the refresh call.

    Regards

    PS: Thanks for your site

    Like

    Reply
      1. François Richard

        Hello

        it’s in R4 and you’re right with the 347 jars in the folder LIB, it works.

        Thanks for your quick return.

        François

        Like

  5. Jen

    Hello,

    Thank you very much for your excellent code. I am using 4.0 trying to save a file to XLSX format. 4.0 says it now supports this format but when I use OutputFormatType.XLSX I get an error.

    Do you know how this can be achieved.

    Thanks much,
    Jen

    Like

    Reply
    1. dmytro Post author

      It works for me.

      BinaryView xlsView = (BinaryView)doc.getView(OutputFormatType.XLSX);
      writeBytes(xlsView.getContent(), title + ".xlsx");
      

      What is the error message?

      Like

      Reply
  6. Priya

    Hi dymtro,

    I try to retrieve the scheduling information for each of the reports in a folder.
    Could you please help me on how i can check whether the report has been scheduled or not and then execute the below one. Otherwise its throws null as the report is not scheduled itself.

    Also it would be great if we have any sample code to retrieve all the schedule related information.

    iRepObject=(IInfoObject) iRepObjects.get(iRepObjs);
    System.out.println(“Report Schedule information IProperties prop = iRepObject.properties();
    System.out.println(“Last Run Time ……..”+prop.getProperty(“SI_LAST_RUN_TIME”).getValue().toString());

    Thanks in advance for your help.

    Like

    Reply
    1. dmytro Post author

      I am not sure if this the easiest way…

      You can get result of two queries:
      A: all reports

      select * from CI_INFOOBJECTS where SI_INSTANCE = 0
      

      B: recurring instances

      select * from CI_INFOOBJECTS where SI_INSTANCE = 1 AND SI_RECURRING = 1
      

      A report from A can have multiple recurring instances in B. There is parent-child relation between them: A.SI_CUID=B.SI_PARENT_CUID. So to determine if a report is scheduled, you need to check if there is a child in recurring reports.

      The scheduling information can be retrieved from the second query.

      Like

      Reply
  7. Sachin

    BinaryView xlsView = (BinaryView)doc.getView(OutputFormatType.XLS);
    writeBytes(xlsView.getContent(), title + “.xls”);

    I want when conversion happens , It ask for the OPEN OR SAVE EXCEL ? HOW CAN I ACHIEVE THAT ?

    THANKS.

    Like

    Reply
    1. dmytro Post author

      I assume you are developing JSP application. You can take a look how it is implemented in BO:

      …\webapps\AnalyticalReporting\viewers\cdz_adv\downloadPDForXLS.jsp

      e.g.

      BinaryView xlsView = (BinaryView)doc.getView(OutputFormatType.XLS);
      int length = xlsView.getContentLength();
      response.setContentLength(length);
      response.setContentType("application/vnd.ms-excel");
      response.setHeader("Content-Disposition", "attachment;filename=\"output.xls\"");
      ServletOutputStream output = response.getOutputStream();
      xlsView.getContent(output);
      Output.close();
      

      Like

      Reply
      1. Sachin

        Hi

        You are right.I am developing the Jsp application , but to generate the .xls and .pdf Ihave used the java class file ,so my question is how to I get the response object into the java class ? can you give me some idea to open or save excel or PDF into the java class

        Like

  8. Serge

    Hello, i am currently working on the preliminary studies for a tool based on BO Java SDK to document the content of Universe & Reports (Dataproviders, Queries Reports, ..) and eventually export universe and reports structures in XML format. Is there a tool in your libraries that is doing that ?
    Thanks. Serge

    Like

    Reply
    1. dmytro Post author

      Hi Serge,
      There is tool for documenting Universes https://bukhantsov.org/2011/09/universe-documenter/ but it exports into Excel. I think it is easier to write own tool rather than to reuse parts of universe documenter because the Designer SDK is quite straightforward.
      I do not have a tool for documenting reports structure. You can search on BOB’s downloads http://www.forumtopics.org/busobj/viewforum.php?f=25.

      Just curious, why do you need the universes and reports structures in XML?

      Like

      Reply
      1. Serge

        hi. thanks for the answer. if I understand the Universe Documenter is based on the .Net SDK , not the Java one, and for the report part we will probably need to dig into details that are only available thru the Java Sdk.
        XML is because our requirement is to feed the structures back into IBM Cognos (Framework Manager, Report Studio, etc.) after proper transformation and those tools take XML as input. in fact they work natively in XML.

        Like

      2. dmytro Post author

        Universe Documenter is using Designer COM SDK. There is no BO Java SDK for universes. You can try to use a Java COM bridge (e.g. JACOB) if you want to use Java instead of Microsoft products.
        There is both Java and NET Report Engine SDK, however NET version is very limited, it is probably not suitable for your needs.

        Like

  9. JC Martin

    Hi dmytro,

    I was able to run the program and send the resulting pdf to a Document Repository web-service for long term storage. It all worked fine and I thank you for sharing your code.

    My only question is that it looks like the code is running interactively. Is there a way to schedule instances and from the result of an instance to get the PDF file? I’m afraid that running all reports interactively will take too long so I was thinking something like, schedule the report in advance and use the SDK to get the resulting PDF to send it. (I guess I would need to check the scheduled parameters to make sure I’m getting the right report).

    Sorry for the long question.

    Like

    Reply
    1. RAGHU

      Hi Dmytro,

      It’s a good idea JC

      If we can read report name and prompts from excel file to run the reports and save PDF.
      The excel file can have report name, prompt1,2,3,…. in its columns which will be read by our SDK code.(user name,password,authenticationmode,server can also be placed some where in excel file)

      It would be great to have such a jar or.exe and excel file combination.

      Regards,
      Raghu

      Like

      Reply
  10. Sachin

    Hi

    Thanks for your replied previously .

    I am successfully generating report into PDF as well as into Excel ,but there is some report which is large soI am getting the message like

    Maximum binary output size limit reached (ERR_WIS_30271)

    I foind into the google but there is says to go into the server and updated the file size for report,

    but I want is there any way from the clinet side to resolve this things ??

    Thanks ..

    Like

    Reply
    1. dmytro Post author

      The only good way to resolve on client side is to reduce the size of the output file (stream) e.g. by adding filters or exporting part of the document.

      Like

      Reply
    2. DongwanKim

      There is option for binary stream size in the WebIltelligenceProcessingServer(CMC).

      Increase “Binary Stream Maximum Size” and try again.

      Like

      Reply
  11. GUnther

    Hi,

    I was hoping you could help me with a problem were having with reportEngine.openDocument. We have some strange behavior, it can take up to 25 minutes before opendocumetn is done. Other times it´s done in 45 seconds using the same report and server.
    Any idea where we can start looking ?
    Thank you.
    23/04/13 10:20:47:181 CEST] PERF>>> reportEngine.openDocument() took 25’34.900ms
    [23/04/13 10:20:47:778 CEST] PERF>>> documentInstance.refresh() took 00’00.597ms
    [23/04/13 10:20:47:841 CEST] PERF>>> documentInstance.getPrompts() took 00’00.063ms
    [23/04/13 10:20:47:841 CEST] PERF>>> populateWebiPrompts() 1 took 00’00.000ms
    [23/04/13 10:20:47:999 CEST] PERF>>> document.save() took 00’00.158ms
    [23/04/13 10:20:48:219 CEST] PERF>>> documentInstance.setPrompts() took 00’00.220ms
    [23/04/13 10:20:48:219 CEST] PERF>>> populateWebiPrompts() 2 took 00’00.000ms
    [23/04/13 10:20:48:313 CEST] PERF>>> cleanup took 00’00.094ms
    [23/04/13 10:20:48:313 CEST] PERF>>> ReportPrompts.setReportPrompts() took 25’36.032ms
    [23/04/13 10:20:48:407 CEST] report scheduled!

    Like

    Reply
    1. dmytro Post author

      The report is run when all prompts are set so it is expected that set prompts takes the most of the execution time.

      How much does it take to refresh the report in Webi? Does the program set all prompts correctly? You can try to retrieve and print the prompt values after you set them.

      Like

      Reply
  12. Kiran

    Hi dmytro

    Can you please update on how to create user prompts?
    In the eg. above u mentioned how to set values to prompts.

    Thanks

    Like

    Reply
    1. dmytro Post author

      This is primarily related to how to create documents. You can start from there and use the documentation to find solution. I believe it is something like:

      ...
      ConditionObject conditionObject = container.createConditionObject(objects.getChildByName("Country"));
      FilterCondition filterCondition = conditionObject.createFilterCondition(Operator.EQUAL);
      ConditionPrompt conditionPrompt = filterCondition.createConditionPrompt("Entrer Country");
      conditionPrompt.setOptional(true);
      ...
      

      Like

      Reply
  13. Priya

    I understand that we will be able to generate the reports in PDF, Excel, HTML formats. Could you please help me to generate the report in Microsoft word document.

    I got to know from surfing that we will not be able to generate word directly. Is it possible to call acrobat XI from webi to convert pdf to word or something. Have you ever come across this scenario? Please help asap.

    Like

    Reply
    1. dmytro Post author

      Perhaps, you can generate report in XLS format and then convert to DOC using Apache POI. I have not done this before.

      Like

      Reply
      1. RAGHU

        Hi Dmytro,

        Can yu please let me know if we can save the report (.wid format) with data as well with out refresh on open option besides PDF, XLS….

        Regards,
        Raghu

        Like

    1. dmytro Post author

      If query has Service, Service Line and Revenue:

      BlockAxis hAxis = reportBlock.getAxis(TableAxis.HORIZONTAL);
      hAxis.addExpr(reportDictionary.getChildByName("Service"));
      hAxis.addExpr(reportDictionary.getChildByName("Service Line"));
      hAxis.addExpr(reportDictionary.getChildByName("Revenue"));
      			
      BlockBreak blockBreak = hAxis.getBlockBreak();
      BreakElement breakElement = blockBreak.createBreakElement(
        reportDictionary.getChildByName("Service Line"));
      breakElement.setFooterVisible(false);
      

      Like

      Reply
  14. Kiran

    dmytro
    Thanks a lot!!!!!!!!

    Can u please tell how to put input controls also?
    Also want to know how to merge domensions?

    Like

    Reply
    1. dmytro Post author

      Reg.megring dimensions. I have not tried this but i assume something like:

      SynchroManager sm=documentInstance.getDictionary().getSynchroManager();
      sm.createLink("merged object name", "some description",  
        reportDictionary.getChildByName("object 1"), 
        reportDictionary.getChildByName("object 2")); 
      

      See also SynchroManager

      Reg. input controls. I do not think there is a public interface for this. Probably com.businessobjects.adv_ivcdzview.InputFormFilters and related classes can do the job. But you will have to spend some time to figure out how to use that since it is not documented anywhere.

      Like

      Reply
      1. Kiran

        Hi Dmytro

        I am trying to Merge the object Year from 2 dataproviders but getting the error NullPointerException in method createLink(Unknown Source)

        The code is
        SynchroManager sm=documentInstance.getDictionary().getSynchroManager();
        sm.createLink(“Year_M”, “mergedYear”,reportDictionary.getChildByName(“Year(Query 1))”),reportDictionary.getChildByName(“Year(Query 2))”));

        Like

      2. dmytro Post author

        Probably you are using wrong name. Is this not null: reportDictionary.getChildByName(“Year(Query 1))”)?

        You can print names of the objects from reportDictionary to see the right names.

        Like

      3. Kiran

        Hi

        The reportDictionary has 2 objects with name Year.
        I tried that also but got below exception:

        Exception in thread “main” com.businessobjects.rebean.wi.ServerException: An internal error occured while calling ‘processDPCommands’ API. (Error: ERR_WIS_30270)
        at com.businessobjects.wp.om.OMHandler.documentLoadingError(Unknown Source)
        at com.businessobjects.wp.xml.XMLLoader.processDPCommands(Unknown Source)
        at com.businessobjects.wp.xml.XMLLoader.processDPCommands(Unknown Source)
        at com.businessobjects.wp.om.synchro.OMSynchroManager.processCommand(Unknown Source)
        at com.businessobjects.wp.om.synchro.OMSynchroManager.createLink(Unknown Source)
        at org.kiran.javatool.MergeMultipleDataProviders.main

        Like

      1. dmytro Post author

        There is a link to documentation. You could see that “dataSourceID – the ID of the universe the new data provider should be based on.” Is your question how to get id of the universe?

        Like

  15. Kiran

    Hi Dmytro

    infoObject.getID() returns int value?
    DataProvider dataProvider = dps.createDP(infoObject.getID(), 0);
    M getting err!!

    Also can u provide any link which has this documentation?

    Like

    Reply
      1. Kiran

        Hi Dmytro

        I tried the above code but getting below error
        “Cannot run an empty query”
        Though i have fetched few objects from the Universe..

        Like

      2. dmytro Post author

        This worked for me. Are you sure that you are adding to the right data provider/query? Check the logic.

        Like

      1. Kiran

        Hi Dmytro

        I am trying to create a utility that will do most of the report development tasks by itself…

        Like

  16. Kiran

    Hi Dmytro

    Is it possible to access the folders of MyFavorites folders thorugh java(which admistrator has created)?
    I can view them thorugh webi, since i have admin access.

    Like

    Reply
    1. dmytro Post author

      Surely it is possible. You should find infoobject corresponding to MyFavorites of Administrator and then find all children.

      Like

      Reply
  17. Jacuz

    Hello All,

    Our app presently creates the reports in desired formats (pdf, excel etc.). But some of the reports take long and the user has to wait for the report to be converted into PDF. So we are scheduling them and allowing the user to come back and view it later. But this functionality we could achieve only with webi.
    Is there a way to ask BOE SDK to format the report in pdf format and keep with it and later at users demand retrieve it in pdf format?
    Please note that our java application does not want to convert to pdf format and physically save it in some location for later retrieval.

    Also, I haev noted that with BO tool one can save the report in formats like pdf, excel or csv etc. I want to integrate this feature via Java code. Can this be done using BOE SDK? I want BO to save my report in PDF format, so that it can be viewed on demand.

    Thanks
    Jacuz

    Like

    Reply
    1. dmytro Post author

      >> Is there a way to ask BOE SDK to format the report in pdf format and keep with it and later at users demand retrieve it in pdf format?

      You can schedule the document with SDK. Almost all that can be done in Webi/Infoview can be done with SDK.

      Like

      Reply
    1. dmytro Post author

      It is not straightforward. You need either to modify the report layout before export or to remove columns from the exported excel spreadsheet.

      Like

      Reply
  18. keith g

    I compile and run this but whenever I set query to get SI_ID=reportid it finds the report but then immediately says finished! what gives?

    Like

    Reply
  19. Vijay

    Hi
    Can you pls help me in resolving my issue. I have a webi 4.0 report in which last 2 columns have few nulls.when I export them to xls file last 2nd column values are not displayed at all. awaiting for reply.
    Thanks much in advance

    Like

    Reply
  20. Priya

    Hi

    We are trying to publish the report block data as webservices and we wanted to consume it to push the data to Java front end for further process.

    Could you please help us on how we can consume the published webservices data? I believe that it will be Qwaas..Please advise.

    Thanks,
    Priya

    Like

    Reply
      1. Priya

        Thanks Dmytro. Could you also help to understand whether we would be able to retrieve the report level data directly (just like recordset where we take datasource level data) other than pulling in other formats like PDF, Excel, XML, HTML. XML data that we get is having the CSS and formatting details also to misguide us. Currently we are not sure how to take the report level data to get the formula, aggregation applied on it.

        Please let me know if I havent made it clear. Kindly help.

        Thanks,
        Priya

        Like

  21. Rajesh

    Hi dmytro

    I am trying to add a dimension object, by default its adding all its detail objects as well.When i am trying to display the dimension object in my report, its showing all detail objects as well, which i dont want.

    Is there any way to restrict the data till dimension object?

    Like

    Reply
    1. dmytro Post author

      You are probably adding by name. Try adding by object id.

      This is similar to class. If you select a class, all objects from the class will be added.

      Like

      Reply
  22. Saurabh

    Hi Dmytro,

    I am trying to use the code provided by you here to export a prompted WEBI report in PDF,XLS format. I have tried for both the single value as well as LOV prompt answers , but for both the cases i am encountering two strange issues:
    1- If i invoke doc.refresh(),after that if i try to use doc.getPrompts(), it gives me indexOutOfBoundException. I believe doc.refresh() refreshes the instance and not the report altogether,so i skipped it.
    2- After entering the prompt values, i called doc.setPrompts() but i get the same
    indexOutOfBoundException again.

    Here is the stackTrace:
    Exception in thread “main” java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at com.sap.sl.sdk.workspace.service.WorkspaceServiceImpl.getParametersList(WorkspaceServiceImpl.java:391)
    at com.businessobjects.rebean.wi.internal.WIDocumentInstance.getParameters(WIDocumentInstance.java:1088)
    at com.businessobjects.rebean.wi.internal.WIDocumentInstance.getPrompts(WIDocumentInstance.java:316)
    at com.businessobjects.rebean.wi.internal.WIDocumentInstance.setPrompts(WIDocumentInstance.java:616)
    at BOE.BOEDocumentExport.main(BOEDocumentExport.java:87)

    Please guide me on the same.
    Thanks,
    Saurabh

    Like

    Reply
  23. DON

    Hi,
    In my application I i get the report any try to convert it to csv using poi. This works fine with BO-3.1 jars.
    But once i use the BO-4 jars and try the same it brings the data correctly but adds blank rows at the start of the csv file. The no. of blank rows is the double of no. of rows of data. The data is viewed properly in pdf format.

    Can you please help?

    Thanks…

    Like

    Reply
      1. DON

        Yes tried didnot work.
        Found a work around took data in .XLSX format. Converted to .csv using poi XSSF.
        But now file size greater than 5 mb(default max char stream size in cmc) doesnot work. This is the “file size” I wonder it takes the whole file at once and writes not like .XLS where it use to write line by line.
        Also even after changing the setting in cmc it gives Out of memory exception on server as poi’s memory footprints are high.
        So can you please try generating a report in bo4 with getContent as .xls and pass this report as input to poi to generate equivalent csv.

        Like

  24. Carlos

    Well, I am not acquainted with the SDK, however, I was wondering if the CSV code you provided could surpass the current limitation regarding the standard CSV output which just generates data from the query and NOT from the report itself, besides, the output comes with headers and text qualifiers.

    Regards.

    Like

    Reply
    1. dmytro Post author

      No. This code provides the same output that you get from user interface. I.e. you will get content of data provider in CSV.

      Like

      Reply
      1. Carlos

        I see. Thanks for the reply, I wonder why SAP decided to do so … the other day, in order to provide a “workaround” I created specific objects in my universe with decodes, substrings, etc which enabled me to get the desired output, however, still had to treat the resulting csv file taking away header and text qualifiers, this is really annoying and supposed even SDK would not allow us to fix this limiting problem.

        Like

  25. Pietras

    Hi.
    Very useful.
    However, when I have updated my BO 4.0 to SP06 I have the error:
    Exception in thread “main” java.lang.NullPointerException
    at com.sap.sl.common.impl.FieldImpl.setDateTime(FieldImpl.java:246)
    at com.businessobjects.rebean.wi.internal.dp.prompt.FormatNumberHelper.formatStringToField(FormatNumberHelper.java:125)
    at com.businessobjects.rebean.wi.internal.dp.prompt.WIPrompt.prepareAnswers(WIPrompt.java:157)
    at com.businessobjects.rebean.wi.internal.dp.prompt.WIPrompts.provideAnswers(WIPrompts.java:99)
    at com.businessobjects.rebean.wi.internal.WIDocumentInstance.setPrompts(WIDocumentInstance.java:616)

    while trying to put date parameter.

    Could you please explain why I have got error mentioned aboive?

    Thank you in advance.

    Like

    Reply
  26. John Gilchrist

    Pietras,

    We too are having the same issue with trying to set date type parameters. Anyone have thoughts on this? We are upgrading from XIR3 SP3. We never had the issues in that version

    Like

    Reply
  27. Bartłomiej Pietraszuk (Pietras)

    Hi,
    In my case issue occurred when I used 12 instead of 24 format of a date(‘PM/AM’). After adding AM/PM my app seems to work.

    So, I suppose you have to strictly verify the format of date.

    Like

    Reply
  28. Tim

    Hi There,

    I am very new to this, I just want to know how to open specific report and save as html and pdf. I tried to modify this code but as i am new i am struggling a lot.

    I started from if i can just log in to cms and it worked fine. my next step was to write code which will say open specific document and save as pdf and html.

    Can anybody help me with that. I am using BO 4.0 SP06

    Like

    Reply
  29. Tim

    Somehow i was able to work that out but it throwing me below error.

    Exception in thread “main” com.businessobjects.sdk.core.server.CommunicationException$UnexpectedServerException: The action cannot be performed.
    at com.businessobjects.sdk.core.exception.ExceptionBuilder.make(ExceptionBuilder.java:144)
    at com.businessobjects.sdk.core.exception.ExceptionBuilder.make(ExceptionBuilder.java:101)
    at com.businessobjects.sdk.core.server.common.CommonRequestHandler.afterProcessing(CommonRequestHandler.java:127)
    at com.businessobjects.sdk.core.server.internal.AbstractServer.processIt(AbstractServer.java:178)
    at com.businessobjects.sdk.core.server.internal.AbstractServer.process(AbstractServer.java:133)
    at com.businessobjects.sdk.core.server.internal.InstanceServer.process(InstanceServer.java:94)
    at com.businessobjects.rebean.wi.impl.services.AbstractRebeanService.sendRequest(AbstractRebeanService.java:56)
    at com.businessobjects.rebean.wi.impl.services.DocumentInstanceManagementServiceImpl.openDocument(DocumentInstanceManagementServiceImpl.java:164)
    at com.businessobjects.rebean.wi.impl.services.DocumentInstanceManagementServiceImpl.openDocument(DocumentInstanceManagementServiceImpl.java:78)
    at com.businessobjects.rebean.wi.internal.WIReportEngine.openDocument(WIReportEngine.java:430)
    at com.businessobjects.rebean.wi.internal.WIReportEngine.openDocument(WIReportEngine.java:439)
    at Test.main(Test.java:65)
    Caused by: com.businessobjects.sdk.core.server.ServerException: The action cannot be performed.
    at com.businessobjects.sdk.core.server.common.CommonRequestHandler.newServerException(CommonRequestHandler.java:260)
    at com.businessobjects.sdk.core.server.common.CommonRequestHandler.createAllServerExceptions(CommonRequestHandler.java:238)
    at com.businessobjects.sdk.core.server.common.CommonRequestHandler.afterProcessing(CommonRequestHandler.java:121)
    … 9 more
    Caused by: com.businessobjects.sdk.core.server.ServerException: Load Driver Call: Initialize
    at com.businessobjects.sdk.core.server.common.CommonRequestHandler.newServerException(CommonRequestHandler.java:260)
    at com.businessobjects.sdk.core.server.common.CommonRequestHandler.createAllServerExceptions(CommonRequestHandler.java:236)
    … 10 more

    I am not sure i am on right track or not.

    Help would be much appropriated.

    Thanks,
    Tim

    Like

    Reply
  30. Tim

    Hi Guys,

    After a day of struggle was able to solve my problems by myself. Its just had to spend more time in terms of understanding the code. So I am all good to go.

    How ever my another question is i want to schedule and email the report in pdf instead of saving in the folder.

    Can anyone please tell me how can i modify this code to achieve that. ?

    Like

    Reply
      1. Tim

        Thank you dmytro,

        I have notices that when I am exporting webi reports using java sdk code given above to html I don’t see any charts ans url in my report.

        Do you know the reason of that ?

        Thank you,
        Tim

        Like

      2. Tim

        Hi dmytro,

        Thank you for your reply.

        I used below code for mhtml.

        Reports reports = widoc.getReports();
        HTMLView htmlView = (HTMLView) reports.getItem(0).getView(OutputFormatType.MHTML);
        FileWriter fw = new FileWriter(“report.mhtml”);
        htmlView.getContent(fw,””,””);fw.close();

        but it comes up with an error saying widoc cannot be resolves. I have all the libraries included as well.

        So don’t know why it is coming up like that. just to try i changes that to doc.getReports(); and worked well. links came up fine but i cant see any chart in that file.

        Do you know any particular thing which i am missing ?

        Thanks,
        Tim

        Like

  31. Phil

    Great code, thanks for your effort.

    But I have an issue :
    When I “setPrompt”, I have an error “failed to execute… WIS10901”
    The full code of the query is displayed and looks good.

    Then context :
    The WebI report works with the prompt values I choose.
    The WebI report use one universe which is based on BEx query.

    My feeling :
    It seems that generated MDX uses references and not values.
    Then instead of [!V000002] INCLUDING “SEP 2013” we have to use [!V000002] INCLUDING [0FISCPER].[K42013007] (by example)

    Do you have any information on that behavior ?

    Like

    Reply
    1. Phil

      I replied myself as I have an idea.
      This is probably caused by the fact that the argument that has been passed to MDX parser is the value of the lov and not the displayed label…

      Then how to manage it ?

      Any idea are welcome 😉

      Like

      Reply
  32. Kevin G

    Very cool stuff. I tried searching through here to see if this was already asked/answered. Can I refresh a webi and save it back to platform?

    Like

    Reply
  33. Kevin G

    Thanks dmytro, now I’m having a compile issue with the code. We are using Eclipse with JRE7 and all the BI 4.0 java libraries. Am I missing something? I believe we are getting an error on this line

    for (Object object : infoObjects)

    Like

    Reply
  34. Kevin G

    I actually have someone else doing the development. They tell me all the BO Libs are added. This is the line we are getting the errors on
    HashMap answers = new HashMap();

    Like

    Reply
    1. dmytro Post author

      Strange. Well, then it is not related with BO SDK. Do they have import java.util.HashMap; in the top of the code?

      Like

      Reply
  35. Kevin G

    Yes I do see that. I hope my java people know this but what does it take to get the java import file references resolved?

    Like

    Reply
  36. Vinita

    Hi Dmytro,

    Thank you so musch for this sample.
    However one problem that I am facing with this code is that the exported report (pdf/excel) just has the first page .
    The pdf file has the first page and the 2nd page just has the header.
    I have tried PaginationMode(Listing and Page ) but it doesnot resolve the issue.

    Can you please help??

    Like

    Reply
  37. Kiran

    Hi Dmytro,
    Firstly thanks for your code. We are able to generate a pdf of our report but the issue is our report has near to 15 columns so in pdf in the first page we have 10 columns and the 2nd page we get the remaining columns. Is there a setting in BO such that all the 15 columns of our reports gets displayed in a single page. How can we achieve this. Thanks for your help.

    Like

    Reply
  38. muscle x men s health

    I’m really impressed together with your writing talents and also with the layout to your blog.

    Is that this a paid subject or did you modify it yourself?

    Either way stay up the excellent quality writing, it is
    uncommon to peer a nice blog like this one these days..

    Like

    Reply
  39. Swamy

    When i am trying to export BO report to CSV through JAVA code ,I am able generate CSV file.

    But in the CSV file im getting data provider query name along with column header,that i dont want in my CSV file.

    Please help me out in this .

    code:

    CSVView csvView = doc.getDataProviders().getItem(0).getResultAsCSV(-1);

    writeBytes(csvView.getContent().getBytes(), reportName +”.csv”, saveDir + requestId);

    In the file im getting “Group number(Unit purchase)” , I dont want the text inside bracket in my CSV.

    Please suggest me on this.

    Like

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s