You are on page 1of 16

10/9/13

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

Bukhantsov.org
Business Intelligence Tools etc BusinessObjects Data Warehousing Databases Programming Software

How to run a webi document and export the result to PDF, Excel etc using BO Java Report Engine SDK
Posted in SDK - 31 January 2013 - 83 comments 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. 2. 3. 4. 5. Open a webi document Run queries Set prompts and contexts Export Close .

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

Open a Webi document


Lets assume that we found an Id of Webi document.
D o c u m e n t I n s t a n c ed o c=r e p o r t E n g i n e . o p e n D o c u m e n t ( i n f o O b j e c t . g e t I D ( ) ) ;

Run queries
The queries can be run using DocumentInstance.refresh() or DataProviders.runQueries().
d o c . r e f r e s h ( ) ;

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.
H a s h M a p < S t r i n g ,S t r i n g [ ] >a n s w e r s=n e wH a s h M a p < S t r i n g ,S t r i n g [ ] > ( ) ; a n s w e r s . p u t ( " C o u n t r y : " ,n e wS t r i n g [ ] { " U S " ," F r a n c e " } ) ; a n s w e r s . p u t ( " Y e a r : " ,n e wS t r i n g [ ] { " F Y 2 0 0 4 " } ) ;

(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).
P r o m p t sp r o m p t s=d o c . g e t P r o m p t s ( ) ; f o r( i n ti=0 ;i<p r o m p t s . g e t C o u n t ( ) ;i + + ){ P r o m p tp r o m p t=p r o m p t s . g e t I t e m ( i ) ; S t r i n g [ ]a n s w e r=a n s w e r s . g e t ( p r o m p t . g e t I D ( ) ) ; i f( a n s w e r! =n u l l ){ p r o m p t . e n t e r V a l u e s ( a n s w e r ) ; } } d o c . s e t P r o m p t s ( ) ;

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.
i f( d o c . g e t M u s t F i l l P r o m p t s ( ) ){ S y s t e m . o u t . p r i n t l n ( " E R R O R :M a n d a t o r yp r o m p t sh a sn o tb e e ne n t e r e d " ) ; }

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.
bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/ 1/16

10/9/13

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

i f( d o c . g e t M u s t F i l l C o n t e x t s ( ) ){ S y s t e m . o u t . p r i n t l n ( " E R R O R :C o n t e x th a sn o tb e e ns e l e c t e d " ) ; }

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.
B i n a r y V i e wb i n a r y V i e w 2=( B i n a r y V i e w ) d o c . g e t V i e w ( O u t p u t F o r m a t T y p e . P D F ) ; S t r i n gt i t l e=i n f o O b j e c t . g e t T i t l e ( ) ; w r i t e B y t e s ( b i n a r y V i e w 2 . g e t C o n t e n t ( ) ,t i t l e+" . p d f " ) ;

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


p u b l i cs t a t i cv o i dw r i t e B y t e s ( b y t e [ ]d a t a ,S t r i n gf i l e n a m e )t h r o w sI O E x c e p t i o n{ F i l ef i l e=n e wF i l e ( f i l e n a m e ) ; F i l e O u t p u t S t r e a mf s t r e a m=n e wF i l e O u t p u t S t r e a m ( f i l e ) ; f s t r e a m . w r i t e ( d a t a ) ; f s t r e a m . c l o s e ( ) ; }

Export to Excel
We can export the document to an Excel file using similar code:
B i n a r y V i e wx l s V i e w=( B i n a r y V i e w ) d o c . g e t V i e w ( O u t p u t F o r m a t T y p e . X L S ) ; w r i t e B y t e s ( x l s V i e w . g e t C o n t e n t ( ) ,t i t l e+" . x l s " ) ;

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:
C S V V i e wc s v V i e w=( C S V V i e w ) d o c . g e t D a t a P r o v i d e r s ( ) . g e t V i e w ( O u t p u t F o r m a t T y p e . C S V ) ; w r i t e B y t e s ( c s v V i e w . g e t C o n t e n t ( ) . g e t B y t e s ( ) ,t i t l e+" . c s v " ) ;

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.
R e p o r t sr e p o r t s=d o c . g e t R e p o r t s ( ) ; f o r( i n ti=0 ;i<r e p o r t s . g e t C o u n t ( ) ;i + + ) { R e p o r tr e p o r t=r e p o r t s . g e t I t e m ( i ) ; r e p o r t . s e t P a g i n a t i o n M o d e ( P a g i n a t i o n M o d e . L i s t i n g ) ; H T M L V i e wh t m l V i e w=( H T M L V i e w )r e p o r t . g e t V i e w ( O u t p u t F o r m a t T y p e . D H T M L ) ; w r i t e B y t e s ( h t m l V i e w . g e t C o n t e n t ( ) . g e t B y t e s ( ) ,t i t l e+""+i+" . h t m l " ) ; }

Done
That is it.
d o c . c l o s e D o c u m e n t ( ) ;
0

Google+ How to determine date pattern for a Webi document using Java RE SDK Removing time part of a date fails in Kettle

83 Responses to How to run a webi document and export the result to PDF, Excel etc using BO Java Report Engine SDK
1. PRAVEEN says: February 6, 2013 at 13:09 Hi, This code is very good. It reduced a lot of efforts. Could you please provide the same for BO 3.1 Regards, Praveen Reply
bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/ 2/16

10/9/13

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

dmytro says: February 6, 2013 at 13:11 It is for BO 3.1 (but should also work for 4.0). Any problem with running it? Reply Sindhu says: February 27, 2013 at 06:09 very nice post,please let me know where to write this code thanks Reply RAGHU says: April 18, 2013 at 07:00 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 Reply 2. RAGHU says: February 7, 2013 at 03:09 Hi, Thanks for the quick response. Its 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 Reply dmytro says: February 7, 2013 at 17:31 Hi Praveen Before doc.setPrompts(), add
D a t es t a r t=n e wD a t e ( ) ;

After doc.setPrompts(), add


D a t ee n d=n e wD a t e ( ) ; d o u b l et i m e s p a n=( e n d . g e t T i m e ( )-s t a r t . g e t T i m e ( ) )/1 0 0 0 . ; S y s t e m . p r i n t l n ( " E x e c u t i o nt i m e :"+t i m e s p a n+"s e c o n d s " ) ;

Reply 3. RAGHU says: February 8, 2013 at 09:05 Hi, Many Thanks. Regards, Praveen Reply 4. JC Martin says: February 8, 2013 at 15:50 Your codes have been very helpful and I appreciate you sharing them. I dont mean to be picky, but just wanted to let you know that one of the sections you say Export to XML instead of Excel.

bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/

3/16

10/9/13

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

Thanks a lot. Your code is really helping me to hit the ground running! Reply dmytro says: February 8, 2013 at 16:48 Corrected. Thank you :) Reply 5. stecas says: February 12, 2013 at 11:12 Hi. I dont undestand where is the path to save exported files. Can you help me? Im newbie of Java. Thanks Stecas Reply dmytro says: February 12, 2013 at 11:24 In the example, the exported files are saved to the current folder. You can specify folder when writing file e.g.
w r i t e B y t e s ( x l s V i e w . g e t C o n t e n t ( ) ," C : \ \ D o c s \ \ "+t i t l e+" . x l s " ) ;

Reply stecas says: February 12, 2013 at 12:51 Wonderful. Thanks for the reply. Ill try this afternoon Reply 6. Syed says: February 15, 2013 at 23:53 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. Reply 7. Franois says: February 27, 2013 at 14:04 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 Reply dmytro says: February 27, 2013 at 14:10 XI 3.x: There is a list of JARs at the end of http://bukhantsov.org/2011/08/getting-started-with-businessobjects-java-sdk/ XI 4.x: Include all JARs from [SAP BusinessObjects]\SAP BusinessObjects Enterprise XI 4.0\java\lib\* (without subfolders) What error did you get?
bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/ 4/16

10/9/13

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

Reply Franois Richard says: February 27, 2013 at 14:41 Hello its in R4 and youre right with the 347 jars in the folder LIB, it works. Thanks for your quick return. Franois Reply 8. Jen says: March 6, 2013 at 20:35 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 Reply dmytro says: March 6, 2013 at 21:29 It works for me.
B i n a r y V i e wx l s V i e w=( B i n a r y V i e w ) d o c . g e t V i e w ( O u t p u t F o r m a t T y p e . X L S X ) ; w r i t e B y t e s ( x l s V i e w . g e t C o n t e n t ( ) ,t i t l e+" . x l s x " ) ;

What is the error message? Reply 9. Priya says: March 15, 2013 at 13:29 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. Reply dmytro says: March 16, 2013 at 08:13 I am not sure if this the easiest way You can get result of two queries: A: all reports
s e l e c t*f r o mC I _ I N F O O B J E C T Sw h e r eS I _ I N S T A N C E=0

B: recurring instances
s e l e c t*f r o mC I _ I N F O O B J E C T Sw h e r eS I _ I N S T A N C E=1A N DS I _ R E C U R R I N G=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.
bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/ 5/16

10/9/13

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

Reply 10. Sachin says: March 16, 2013 at 04:15 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. Reply dmytro says: March 16, 2013 at 07:16 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.
B i n a r y V i e wx l s V i e w=( B i n a r y V i e w ) d o c . g e t V i e w ( O u t p u t F o r m a t T y p e . X L S ) ; i n tl e n g t h=x l s V i e w . g e t C o n t e n t L e n g t h ( ) ; r e s p o n s e . s e t C o n t e n t L e n g t h ( l e n g t h ) ; r e s p o n s e . s e t C o n t e n t T y p e ( " a p p l i c a t i o n / v n d . m s e x c e l " ) ; r e s p o n s e . s e t H e a d e r ( " C o n t e n t D i s p o s i t i o n " ," a t t a c h m e n t ; f i l e n a m e = \ " o u t p u t . x l s \ " " ) ; S e r v l e t O u t p u t S t r e a mo u t p u t=r e s p o n s e . g e t O u t p u t S t r e a m ( ) ; x l s V i e w . g e t C o n t e n t ( o u t p u t ) ; O u t p u t . c l o s e ( ) ;

Reply Sachin says: March 18, 2013 at 09:39 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 Reply 11. Serge says: March 19, 2013 at 11:17 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 Reply dmytro says: March 19, 2013 at 11:57 Hi Serge, There is tool for documenting Universes http://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 BOBs downloads http://www.forumtopics.org/busobj/viewforum.php?f=25. Just curious, why do you need the universes and reports structures in XML? Reply Serge says: March 19, 2013 at 12:54 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. Reply dmytro says: March 19, 2013 at 13:08 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.
bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/ 6/16

10/9/13

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

There is both Java and NET Report Engine SDK, however NET version is very limited, it is probably not suitable for your needs. Reply 12. JC Martin says: March 19, 2013 at 13:53 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? Im 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 Im getting the right report). Sorry for the long question. Reply RAGHU says: April 12, 2013 at 02:50 Hi Dmytro, Its 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 Reply 13. Sachin says: March 26, 2013 at 12:36 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 .. Reply dmytro says: April 5, 2013 at 11:45 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. Reply DongwanKim says: September 30, 2013 at 06:40 There is option for binary stream size in the WebIltelligenceProcessingServer(CMC). Increase Binary Stream Maximum Size and try again. Reply 14. GUnther says: April 23, 2013 at 14:05 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 its done in 45 seconds using the same report and server.
bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/ 7/16

10/9/13

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

Any idea where we can start looking ? Thank you. 23/04/13 10:20:47:181 CEST] PERF>>> reportEngine.openDocument() took 2534.900ms [23/04/13 10:20:47:778 CEST] PERF>>> documentInstance.refresh() took 0000.597ms [23/04/13 10:20:47:841 CEST] PERF>>> documentInstance.getPrompts() took 0000.063ms [23/04/13 10:20:47:841 CEST] PERF>>> populateWebiPrompts() 1 took 0000.000ms [23/04/13 10:20:47:999 CEST] PERF>>> document.save() took 0000.158ms [23/04/13 10:20:48:219 CEST] PERF>>> documentInstance.setPrompts() took 0000.220ms [23/04/13 10:20:48:219 CEST] PERF>>> populateWebiPrompts() 2 took 0000.000ms [23/04/13 10:20:48:313 CEST] PERF>>> cleanup took 0000.094ms [23/04/13 10:20:48:313 CEST] PERF>>> ReportPrompts.setReportPrompts() took 2536.032ms [23/04/13 10:20:48:407 CEST] report scheduled! Reply dmytro says: April 23, 2013 at 14:19 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. Reply 15. Kiran says: May 8, 2013 at 13:16 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 Reply dmytro says: May 8, 2013 at 13:26 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:
. . . C o n d i t i o n O b j e c tc o n d i t i o n O b j e c t=c o n t a i n e r . c r e a t e C o n d i t i o n O b j e c t ( o b j e c t s . g e t C h i l d B y N a m e ( " C o u n t r y " ) ) ; F i l t e r C o n d i t i o nf i l t e r C o n d i t i o n=c o n d i t i o n O b j e c t . c r e a t e F i l t e r C o n d i t i o n ( O p e r a t o r . E Q U A L ) ; C o n d i t i o n P r o m p tc o n d i t i o n P r o m p t=f i l t e r C o n d i t i o n . c r e a t e C o n d i t i o n P r o m p t ( " E n t r e rC o u n t r y " ) ; c o n d i t i o n P r o m p t . s e t O p t i o n a l ( t r u e ) ; . . .

Reply 16. Priya says: May 13, 2013 at 21:15 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. Reply dmytro says: May 14, 2013 at 10:26 Perhaps, you can generate report in XLS format and then convert to DOC using Apache POI. I have not done this before. Reply RAGHU says: June 6, 2013 at 03:14 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 Reply
bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/ 8/16

10/9/13

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

dmytro says: June 6, 2013 at 07:30 You can download Wid file but you need to have the corresponding infoobject. http://bukhantsov.org/2012/07/how-to-retrieve-wid-file-for-a-web-intelligence-document/ So if you want change some report options, you probably need to (1) create a copy of the report, (2) refresh it, (3) change options, (4) save WID, and (5) remove the copy at the end. Reply 17. Kiran says: May 16, 2013 at 10:27 Can we put breaks also through sdk in a webi document? Reply dmytro says: May 17, 2013 at 07:52 If query has Service, Service Line and Revenue:
B l o c k A x i sh A x i s=r e p o r t B l o c k . g e t A x i s ( T a b l e A x i s . H O R I Z O N T A L ) ; h A x i s . a d d E x p r ( r e p o r t D i c t i o n a r y . g e t C h i l d B y N a m e ( " S e r v i c e " ) ) ; h A x i s . a d d E x p r ( r e p o r t D i c t i o n a r y . g e t C h i l d B y N a m e ( " S e r v i c eL i n e " ) ) ; h A x i s . a d d E x p r ( r e p o r t D i c t i o n a r y . g e t C h i l d B y N a m e ( " R e v e n u e " ) ) ; B l o c k B r e a kb l o c k B r e a k=h A x i s . g e t B l o c k B r e a k ( ) ; B r e a k E l e m e n tb r e a k E l e m e n t=b l o c k B r e a k . c r e a t e B r e a k E l e m e n t ( r e p o r t D i c t i o n a r y . g e t C h i l d B y N a m e ( " S e r v i c eL i n e " ) ) ; b r e a k E l e m e n t . s e t F o o t e r V i s i b l e ( f a l s e ) ;

Reply 18. Kiran says: May 17, 2013 at 11:46 dmytro Thanks a lot!!!!!!!! Can u please tell how to put input controls also? Also want to know how to merge domensions? Reply dmytro says: May 17, 2013 at 16:26 Reg.megring dimensions. I have not tried this but i assume something like:
S y n c h r o M a n a g e rs m = d o c u m e n t I n s t a n c e . g e t D i c t i o n a r y ( ) . g e t S y n c h r o M a n a g e r ( ) ; s m . c r e a t e L i n k ( " m e r g e do b j e c tn a m e " ," s o m ed e s c r i p t i o n " , r e p o r t D i c t i o n a r y . g e t C h i l d B y N a m e ( " o b j e c t1 " ) , r e p o r t D i c t i o n a r y . g e t C h i l d B y N a m e ( " o b j e c t2 " ) ) ;

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. Reply Kiran says: May 21, 2013 at 17:46 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)))); Reply dmytro says: May 21, 2013 at 17:57
bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/ 9/16

10/9/13

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

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. Reply Kiran says: May 21, 2013 at 18:23 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 19. Kiran says: May 21, 2013 at 10:52 How to add 2 universes to a report? Reply dmytro says: May 21, 2013 at 10:56 You can add second universe with:
d o c u m e n t I n s t a n c e . g e t D a t a P r o v i d e r s ( ) . c r e a t e D P ( d a t a S o u r c e I D ,i n d e x )

Reply Kiran says: May 21, 2013 at 11:42 how to get Datasourceid? Reply dmytro says: May 21, 2013 at 11:53 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? Reply Kiran says: May 21, 2013 at 11:55 yes. dmytro says: May 21, 2013 at 12:00 See Create new document on http://bukhantsov.org/2013/04/how-to-create-a-webi-document-using-java-report-engine-sdk/ how to query CMS and find infoobject corresponding to the universe. Then
d p s . c r e a t e D P ( i n f o O b j e c t . g e t I D ( ) ,0 ) ;

20.

Kiran says: May 21, 2013 at 12:12 Hi Dmytro infoObject.getID() returns int value? DataProvider dataProvider = dps.createDP(infoObject.getID(), 0); M getting err!!

bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/

10/16

10/9/13

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

Also can u provide any link which has this documentation? Reply dmytro says: May 21, 2013 at 12:24 try
d p s . c r e a t e D P ( " U n i v C U I D = " + i n f o O b j e c t . g e t C U I D ( ) ,0 ) ;

Reply Kiran says: May 21, 2013 at 12:43 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.. Reply dmytro says: May 21, 2013 at 12:51 This worked for me. Are you sure that you are adding to the right data provider/query? Check the logic. Reply Kiran says: May 21, 2013 at 14:02 Ya It worked for me also :) Thanks a lot!!!!!!!!!! dmytro says: May 21, 2013 at 12:30 http://help.sap.com/javadocs/boe/xi31/ java documentation Reply dmytro says: May 21, 2013 at 16:57 Just curious, what are you developing? Reply Kiran says: May 21, 2013 at 17:50 Hi Dmytro I am trying to create a utility that will do most of the report development tasks by itself Reply 21. Kiran says: May 29, 2013 at 11:21 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. Reply dmytro says: June 6, 2013 at 07:40 Surely it is possible. You should find infoobject corresponding to MyFavorites of Administrator and then find all children. Reply

bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/

11/16

10/9/13

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

22.

Jacuz says: May 30, 2013 at 23:03 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 Reply dmytro says: June 11, 2013 at 22:00 >> 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. Reply

23.

Kiran says: June 11, 2013 at 13:28 Hi dmytro How to add associated dimension to a detail varaible? Reply dmytro says: June 11, 2013 at 21:56 http://help.sap.com/javadocs/boe/xi31/re/en/com/businessobjects/rebean/wi/VariableExpression.html#setAssociatedDimension(com.businessobjects.rebean.wi.ReportExpression) Reply

24.

Jennifer says: June 17, 2013 at 17:45 can you apply column filters as part of an Excel file exported from Business Objects? Reply dmytro says: June 17, 2013 at 18:01 It is not straightforward. You need either to modify the report layout before export or to remove columns from the exported excel spreadsheet. Reply

25.

keith g says: June 28, 2013 at 01:11 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? Reply dmytro says: June 28, 2013 at 01:17 Have you removed the condition
i f( p a t h . e q u a l s ( n a m e ) )

? Reply 26. Vijay says: July 10, 2013 at 18:20


12/16

bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/

10/9/13

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

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 Reply dmytro says: July 10, 2013 at 18:39 Are the values exported if you save the document as Excel from Webi interface? Reply Vijay says: July 10, 2013 at 18:44 yes last column values are displayed in the excel but not the 2nd last column. Reply 27. Priya says: July 12, 2013 at 11:24 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 Reply dmytro says: August 8, 2013 at 21:58 http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70094744-4144-2f10-64a1-f2e4f74e282a? QuickLink=index&overridelayout=true&53824530166488 or search Consuming Query as a Web Services in .NET and Java Applications Reply Priya says: August 19, 2013 at 11:04 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 Reply 28. Rajesh says: July 12, 2013 at 14:49 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? Reply dmytro says: August 8, 2013 at 22:04 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. Reply
bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/ 13/16

10/9/13

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

29.

Saurabh says: August 6, 2013 at 12:13 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 Reply dmytro says: August 8, 2013 at 21:55 It is not working for a specific report or for any report? What is the version and SP of BO? Reply

30.

DON says: August 7, 2013 at 17:53 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 Reply dmytro says: August 8, 2013 at 21:31 Have you tried OutputFormatType.XLSDataCentric? Reply

Leave a Reply
Required fields are marked * Name * Email (your email address will not be published) * Website (leave blank if you are human)

Comment You may use these HTML tags and attributes: < ah r e f = " "t i t l e = " " >< a b b rt i t l e = " " >< a c r o n y mt i t l e = " " >< b >< b l o c k q u o t ec i t e = " " >< c i t e >< c o d e >< d e l
bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/ 14/16

10/9/13

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

d a t e t i m e = " " >< e m >< i >< qc i t e = " " >< s t r i k e >< s t r o n g > Post Comment search this site Search

Categories Business Objects Administration SDK Tools Universe Designer Web Intelligence Xcelsius Data Warehousing Design Kettle Methodology OLAP Databases Oracle SQL Server Programming C# Flex Java Javascript Python Other Recent Comments dbourlet on InfoStore Query Builder (with export to Excel) dmytro on How to change universe of a webi document using BO RE Java SDK Doug on How to change universe of a webi document using BO RE Java SDK Berend on InfoStore Query Builder (with export to Excel) Matt on Calculated Default Value for a Prompt DBourlet on InfoStore Query Builder (with export to Excel) fa on Universe Documenter DongwanKim on How to run a webi document and export the result to PDF, Excel etc using BO Java Report Engine SDK Ibrahim H. on Getting started with BusinessObjects Java SDK Sandeep Chandran on Java code to list the objects used in a Webi 4.0 document Tags
administration batch file bug businessobjects calculation context c sharp reflection sas

designer diff execution plan feature fix pack flex forcemerge hierarchical query index java javascript kettle list of values loop private web intelligence

sdk

service pack sql todate tomcat universe userresponse webi

Archives April 2013 March 2013 February 2013 January 2013 December 2012 November 2012 September 2012 August 2012 July 2012 June 2012 May 2012 April 2012 March 2012 February 2012 January 2012 December 2011 November 2011 October 2011 September 2011 August 2011
bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/ 15/16

10/9/13

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

About This is a blog about business intelligence, data warehousing, databases, programming etc.

The opinions expressed here represent my own and may or may not reflect the opinions or policies of my employer.

The site is not endorsed by or affiliated with SAP, SAS, Oracle, Microsoft etc

The information, source code, and software available on this web site is provided "as is " without warranty of any kind blah-blah-blah... Copyright 2013 Bukhantsov.org. Entries (RSS). Clean Simple White Theme by Mazznoer. Powered by WordPress. Business Intelligence Tools etc

bukhantsov.org/2013/01/how-to-run-a-webi-document-and-export-the-result-using/

16/16