cancel
Showing results for 
Search instead for 
Did you mean: 

How to purge report data before deployment on target server

Former Member
0 Kudos

Hi, guys,

I need your help badly.

I'm trying to find some way to purge report data programatically using SDK. The reason behind is the report is built and tested on development server but then it needs to be deployed to customer site but original data should not being viewed and that is why they need to be purged during before deployment. Manually using InvoView it takes time to purge for each report, one by one.

I've found that there is a method purge() under IDataProvider for ReportEngine and no exampes.

Looking around I've found at Diamond Tech Community one reference called Java_ Enterprise_BE115_Purge-Report-Instances under URL: https://boc.sdn.sap.com/node/6008 but I not able to download the zip file. I'm not sure that it is the right one (they talk about report instances and I need to purge data w/o using InfoView manually)

Pls, advice how to do the thing.

thx

Michael

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

I would like to say thank you to Mr. Shawn Penner (I was searching for the GetSql method and likely i found this thread , very useful code snippet

thanks

krish RAJAN

Former Member
0 Kudos

thanks to everybody for participation

It is better to know than keep trying

Former Member
0 Kudos

Dan, thanks a lot for your clarification.

The case can be closed

Michael

Former Member
0 Kudos

Shawn, thank you.

I've been here exactly, but I can not purge method for any objects: DataProvider, SQLDataProvider and SQLContainer.

Could you, pls, clarify?

Michael

dan_cuevas
Active Participant
0 Kudos

Hi,

I just want to make some clarifications with regards to this post.

The purge() method off the DataProvider class is only available in XI 3.0 and is not available in XI R2.

Unfortunately, there is no way to purge the data provider in XI R2 using the SDK.

Regards,

Dan

former_member203619
Contributor
0 Kudos

Hi Michael,

The sample that you linked to doesn't purge data from a report, what it actually does is go in an delete all the instances from a specified report.

From the description you gave, I am going to assume that you are using webi reports, and not crystal reports - since with crystal reports you would not be using the reportengine SDK.

I don't have any sample code that calls the purge method, but I do have some code that demonstrates how to load the report and retrieve the data providers.


<%@ 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 = "testSystem";
String password = "";
String cmsname  = "D3-2003S-BOXI2";
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 = request.getParameter("id");
	String docname = "Multi DP WebI";

	//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;
		SQLDataProvider oSQLDataProvider = null;
		SQLContainer oSQLContainer_root = null;
		SQLNode oSQLNode = null;
		SQLSelectStatement oSQLSelectStatement = null;
		String sqlStatement = null;

		out.print("<TABLE BORDER=1>");
		for (int i=0; i<oDocumentInstance.getDataProviders().getCount(); i++) {
			oDataProvider = oDocumentInstance.getDataProviders().getItem(i);
			out.print("<TR><TD COLSPAN=2 BGCOLOR=KHAKI>Data Provider Name: " + oDataProvider.getName() + "</TD></TR>");

			oSQLDataProvider = (SQLDataProvider) oDataProvider;

			oSQLContainer_root = oSQLDataProvider.getSQLContainer();

			if (oSQLContainer_root != null) {
				for (int j=0; j<oSQLContainer_root.getChildCount(); j++) {
					oSQLNode = (SQLNode) oSQLContainer_root.getChildAt(j);

					oSQLSelectStatement = (SQLSelectStatement) oSQLNode;
							
					sqlStatement = oSQLSelectStatement.getSQL();
					out.print("<TR><TD>" + (j+1) + "</TD><TD>" + sqlStatement + "</TD></TR>");
				}
			}
		}
		out.print("</TABLE>");

		oDocumentInstance.closeDocument();
	}
}
%>

The modifications that you would need to do to this code are:

1. Instead of looking at the SQL, call the purge method

2. Save the document back before closing it.

Regards,

Shawn