Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member184995
Active Contributor

In previous versions of BusinessObjects (6.5 and prior) application developers had the ability to purge saved data from Webi documents.

With the move to the Enterprise backend this functionality was not migrated over.

BusinessObjects Enterprise XI 3.1 has added this functionality back into the Java REBean SDK.  You can now purge saved data from a Webi template as well as reset the prompt values that were used during the last refresh of the report.

 

bq. Entire code page in JSP<br /><textarea cols="75" rows="10"><%@ page import="com.crystaldecisions.sdk.framework.*" %>
<%@ page import="com.crystaldecisions.sdk.exception.SDKException" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.*" %>
<%@ page 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) {
          out.print("<FONT COLOR=RED><B>Unable to login.</B></FONT>");
     } else {
          loginSuccessful = true;
     }
} catch (SDKException sdkEx) {
     out.print("<FONT COLOR=RED><B>ERROR ENCOUNTERED</B><BR>" + sdkEx + "</FONT>");
}

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();
}
%>
</textarea>

7 Comments