system
October 1, 2012, 1:31pm
1
Hi All,
my code works fine on BOXI 3.1, unfortunately on BOXI4.0 the WebIntelligence report is not refreshed with the values filled. I use the follow jar directly from BOXI 31. version beacuse if I use BOXI 4.0 version the JAva program goes in error :
XI31 Jar Version :
xpp3
xpp3_min
xpp3-1.1.3.3
rebean
rebean.common
rebean.wi
Here my code :
package Bursting;
import com.crystaldecisions.sdk.framework.;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.occa.infostore. ;
import com.crystaldecisions.sdk.plugin.CeKind;
//import com.businessobjects.sdk.plugin.desktop.webi.;
import com.crystaldecisions.sdk.properties. ;
import java.util.;
import com.businessobjects.rebean.wi. ;
import com.businessobjects.sdk.ceutils.prompts.*;
import com.businessobjects.rebean.wi.DocumentInstance;
import com.businessobjects.rebean.wi.ReportDictionary;
import com.businessobjects.rebean.wi.ReportEngine;
import com.businessobjects.rebean.wi.ReportEngines;
import com.businessobjects.rebean.wi.VariableExpression;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.framework.ISessionMgr;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.businessobjects.sdk.plugin.desktop.publication.IPublication;
import com.crystaldecisions.sdk.occa.infostore.IProcessingInfo;
import com.crystaldecisions.sdk.properties.IProperties;
import com.crystaldecisions.sdk.properties.IProperty;
import com.businessobjects.sdk.ceutils.prompts.*;
import com.crystaldecisions.sdk.plugin.CeKind;
import com.businessobjects.rebean.wi.ReportEngines.ReportEngineType;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class SPR {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
IEnterpriseSession enterpriseSession = null;
ReportEngines reportEngines = null;
String vout="";
FileReader fr = new FileReader("/PDF/ListPrompt.txt"); //Input File used for assigning prompt values, ex //Server1/c:/prompts.csv
//Read in source file for prompt values
BufferedReader br = new BufferedReader(fr);
String DateInput;
int iListlenght=0;
String vPromptValue1 = "";
ArrayList<String> PromptList = new ArrayList<String>();
String sReader = br .readLine();
while(sReader!=null){
PromptList.add(sReader);
sReader = br.readLine();
}
//close prompt input file
br.close();
fr.close();
try {
System.out.println("Connecting...");
ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
enterpriseSession = sessionMgr.logon("Administrator","XXX", "PPP", "secEnterprise");
reportEngines = (ReportEngines) enterpriseSession.getService("ReportEngines");
ReportEngine wiRepEngine = (ReportEngine) reportEngines.getService(ReportEngines.ReportEngineType.WI_REPORT_ENGINE);
/*IInfoStore infoStore =
(IInfoStore) enterpriseSession.getService("InfoStore");
String query = "select SI_NAME, SI_ID from CI_INFOOBJECTS "
+ "where SI_KIND = 'Webi' and SI_NAME='Year_Revenue2'";
IInfoObjects infoObjects = (IInfoObjects) infoStore.query(query);
System.out.println("infoObjects" + infoObjects);*/
for (int i=0; i<PromptList.size(); i++){
//System.out.println("infoObject.getID()" + infoObject.getID());
DocumentInstance widoc = wiRepEngine.openDocument(6934);
System.out.println("aa --> "+ widoc);
//Assign a value to each prompt in the report.
Prompts prompts = widoc.getPrompts();
System.out.println("prompts.getCount() ---> " + prompts.getCount());
for(int j =0, m = prompts.getCount();j<m; j++)
{
Prompt prompt = prompts.getItem(j);
String name = prompt.getName();
System.out.println("numero prompt --> " + name);
String str[] = prompt.getPreviousValues();
//String VAL = PromptList.get(i).toString();
//int AA = 2004+i;
//String sAA = AA + "";
String [] values = {PromptList.get(i).toString()};
prompt.enterValues(values);
widoc.setPrompts();
String s[] = prompt.getCurrentValues();
System.out.println("Valore corrente --> " + PromptList.get(i).toString());
widoc.refresh();
widoc.save();
//DocumentInstance oDocument = reportEngine.openDocument(reportID);
BinaryView oBinaryView = (BinaryView) widoc.getView(OutputFormatType.PDF);
//String vFilePath="/bo/BOFlatfiles/"tmpWebi.getTitle()".pdf";
String vFilePath="/PDF/Year_Revenue"+ PromptList.get(i).toString() +".pdf";
File vFile = new File(vFilePath);
FileOutputStream fstream = new FileOutputStream(vFilePath);
fstream.write(oBinaryView.getContent());
widoc.closeDocument();
}
}
System.out.println("success prompts");
}
catch (SDKException ex) {
ex.printStackTrace();
}
finally {
if (reportEngines != null)
reportEngines.close();
if (enterpriseSession != null)
enterpriseSession.logoff();
}
System.out.println("Finished!");
}
public static void printDocumentVariables(DocumentInstance widoc ) {
ReportDictionary dic = widoc.getDictionary();
VariableExpression[] variables = dic.getVariables();
for (VariableExpression e : variables) {
String name = e.getFormulaLanguageID();
String expression = e.getFormula().getValue();
System.out.println(" " + name + " " + expression);
}
}
public static String getInfoObjectPath(IInfoObject infoObject)
throws SDKException {
String path = "";
while (infoObject.getParentID() != 0) {
infoObject = infoObject.getParent();
path = "/" + infoObject.getTitle() + path;
}
return path;
}
}
If I refresh a report without prompt It works fine…
Any Idea… ?
Regards,
ZAV
zavatta_fighter (BOB member since 2005-05-10)
system
October 1, 2012, 5:38pm
2
system
October 2, 2012, 4:15pm
3
Thank You Dmytro Bukhantsov… I solved adding your code.
Best Regards,
ZAV
zavatta_fighter (BOB member since 2005-05-10)
Hello Dmytro Bukhantsov,
I was successful in getting the report from BO4.1 and Universe in 3.1 but when we upgraded the universe the 4.1 prompts.getItem retuns null. Do you have any idea why it is doing this?
Thanks!
hemanthkolla (BOB member since 2016-05-24)
The Java Report Engine SDK has been deprecated in BI4.1. Some things still work but others don’t.
SAP suggests using the new REST API instead.
joepeters (BOB member since 2002-08-29)