Skip to content

Instantly share code, notes, and snippets.

@acnithin
Created August 22, 2012 16:15
Show Gist options
  • Save acnithin/3427117 to your computer and use it in GitHub Desktop.
Save acnithin/3427117 to your computer and use it in GitHub Desktop.
BO Java SDK-purging report data
import com.crystaldecisions.sdk.framework.*
import="com.crystaldecisions.sdk.exception.SDKException
import="com.crystaldecisions.sdk.occa.infostore.*
import com.businessobjects.rebean.wi.*
boolean loginSuccessful = false;
IEnterpriseSession oEnterpriseSession = null;
String username = "Administrator";
String password = "MyPassword";
String cmsname = "localhost";
String authenticationType = "secEnterprise";
try {
//Log in.
oEnterpriseSession = CrystalEnterprise.getSessionMgr().logon( username, password, cmsname,authenticationType);
if (oEnterpriseSession == null) {
} else {
loginSuccessful = true;
}
} catch (SDKException sdkEx) {
}
if (loginSuccessful) {
IInfoObject oInfoObject = null;
String docname = "TestWebi";
//Grab the InfoStore from the httpsession
IInfoStore oInfoStore = (IInfoStore) oEnterpriseSession.getService("", "InfoStore");
//Query for the report object in the CMS. See the Developer Reference guide for more information the query language.
String query = "SELECT TOP 1 * " +"FROM CI_INFOOBJECTS " + "WHERE SI_INSTANCE = 0 And SI_Kind = 'Webi' " +"AND SI_NAME='" + docname + "'";
IInfoObjects oInfoObjects = (IInfoObjects) oInfoStore.query(query);
if (oInfoObjects.size() > 0) {
//Retrieve the latest instance of the report
oInfoObject = (IInfoObject) oInfoObjects.get(0);
// Initialize the Report Engine
ReportEngines oReportEngines = (ReportEngines) oEnterpriseSession.getService("ReportEngines");
ReportEngine oReportEngine = (ReportEngine) oReportEngines.getService(ReportEngines.ReportEngineType.WI_REPORT_ENGINE);
// Openning the document
DocumentInstance oDocumentInstance = oReportEngine.openDocument(oInfoObject.getID());
DataProvider oDataProvider = null;
//Loop through dataproviders and purge data
for (int i=0; i<oDocumentInstance.getDataProviders().getCount(); i++) {
oDataProvider = oDocumentInstance.getDataProviders().getItem(i);
oDataProvider.purge();
// This option purges data as well as reset prompt values used during last refresh
//oDataProvider.purge(true);
}
oDocumentInstance.save();
oDocumentInstance.closeDocument();
}
oEnterpriseSession.logoff();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment