Skip to Content
SBOP SDK

Base Scripting Template for InfoObjects

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 infoobjects an enterprise system and opening them 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,
com.crystaldecisions.sdk.framework.*,
com.crystaldecisions.sdk.occa.infostore.*,
com.crystaldecisions.sdk.occa.report.*,
com.crystaldecisions.sdk.properties.*,
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;

for(;;) {

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

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

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

  // Here is where you would do all the needed work / modifications
  out.println("The objects is titled " + boObject.getTitle());

  max_id = boObject.getID();
}
infoStore.commit(boInfoObjects);
}
out.println("Completed</br>");

%>