Skip to Content

Base Scripting Template for Crystal Reports


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 crystal reports on an enterprise system and opening them using RAS to perform some kind of modification.  This code will work on a BOE XI 3.1 and a BI4 system.

Code Sample

<%@ page import = "com.crystaldecisions.sdk.exception.SDKException,
// 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;

// Obtain the necessary RAS factory for opening reports.
IReportAppFactory reportAppFactory=(IReportAppFactory) enterpriseSession.getService("","RASReportService");

for(;;) {

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

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

for(Iterator boCount = boInfoObjects.iterator() ; boCount.hasNext() ; ) {
  IInfoObject boReport = (IInfoObject);
  // Open the report with RAS
  ReportClientDocument rcDocument=reportAppFactory.openDocument(boReport.getID(),0,Locale.ENGLISH); 

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


No comments