Skip to Content
SBOP SDK

Base Scripting Template for Webi Reports

Tags:

When using SAP BusinessObjects Enterprise, there are times where it is useful to perform an action on all objects of a particular type.  For example, if you want to delete all instances of a report, or you want to remap the universes for all webi reports.  For these types of tasks, a script can be very useful and significantly faster than making the changes manually.

The code below can be used as a template for looping through all webi reports on an enterprise system and opening them to perform some kind of modification.  This code will only work on a BOE XI 3.1 system.

Code Sample

<%@ page import = "com.crystaldecisions.sdk.exception.SDKException,
com.crystaldecisions.sdk.framework.*,
com.crystaldecisions.sdk.occa.infostore.*,
com.crystaldecisions.sdk.occa.report.*,
com.crystaldecisions.sdk.properties.*,
com.businessobjects.rebean.wi.*,
java.util.*"
%>


<%
// User Credentials
String username = "Administrator";
String password = "myPassword";
String cmsname  = "myEnterpriseServer";
String authType = "secEnterprise";

IEnterpriseSession enterpriseSession = null;
IInfoStore infoStore;
IInfoObjects boInfoObjects;

// Log onto Enterprise
enterpriseSession = CrystalEnterprise.getSessionMgr().logon(username, password, cmsname, authType);
infoStore = (IInfoStore)enterpriseSession.getService("", "InfoStore");

// The SI_ID to start at when searching
int max_id = 0;

ReportEngines boReportEngines = (ReportEngines) boEnterpriseSession.getService("ReportEngines");

for(;;) {

// Loop through all objects
boInfoObjects = (IInfoObjects)infoStore.query("Select TOP 100* FROM CI_INFOOBJECTS WHERE SI_KIND='Webi' AND SI_ID > " + max_id + " ORDER BY SI_ID ASC");

// If there are no more objects then we're done.
if(boInfoObjects.size() == 0)
break;

ReportEngine boReportEngine = (ReportEngine) boReportEngines.getService(ReportEngines.ReportEngineType.WI_REPORT_ENGINE);

for(Iterator boCount = boInfoObjects.iterator() ; boCount.hasNext() ; ) {
  IInfoObject boReport = (IInfoObject)boCount.next();

  DocumentInstance boDocumentInstance = boReportEngine.openDocument(boReport.getID());

  // Here is where you would do all the needed work / modifications
 
  boDocumentInstance.save(); // If you made any changes that need to be saved you would include this line.
  boDocumentInstance.closeDocument();

  max_id = boObject.getID();
}

boReportEngine.close()
infoStore.commit(boInfoObjects);
}
out.println("Completed</br>");

%>