Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

I am writing this blog as an extension to the document available at Java Enterprise BE12 Get Webi Report Objects

If there is a change in the object definition in a universe it becomes necessary to know how many reports would get affected in BusinessObjects by this change. The following code provides a way to get the universe objects used in dataproviders of a web intelligence document. Additionally ,it retrieves the class definition for all the objects which makes it easier to track down if two objects have similar name but belong to different classes.

While running the code, you have to provide a folder id, for which you want all the webi report data objects. This will also bring reports in sub folders.

For more scripts and information on how to run these scripts refer to the blog avaiable here:

shawn.penner/blog/2013/06/04/scripts-and-samples

Below is the Java Server Pages (JSP) sample

Note:

•You would need to change the userName, password, cmsName  to the values specific to your enterprise server in the provided sample code.

• The sample code will only run with BO XI 3.1 version of SAP BusinessObjects Platform


UniverseObjects in webi dataprovider

<html>

<body>

<%@ page import="com.crystaldecisions.sdk.framework.*,

               com.crystaldecisions.sdk.occa.infostore.*,

             com.businessobjects.rebean.wi.*,

  java.io.*"

%>

<%

  //Enter Username

  String username = "username";

  //Enter User password

  String password = "password";

  //Enter CMS Name

  String cmsname = "cmsname";

  String authtype = "secEnterprise";

  //Enter the folder if for which you need to retrieve the webi reports objects

  int report_folder_id=2750278;

  IEnterpriseSession oEnterpriseSession=null;

  ReportEngines engines=null;

  ReportEngine widocRepEngine=null;

  try

  {

  oEnterpriseSession = CrystalEnterprise.getSessionMgr().logon(username, password, cmsname, authtype);

  engines = (ReportEngines) oEnterpriseSession.getService("ReportEngines");

  widocRepEngine = (ReportEngine) engines.getService(ReportEngines.ReportEngineType.WI_REPORT_ENGINE);

  getReportObjectsInFolder(oEnterpriseSession,widocRepEngine,report_folder_id,out);

  }

  catch(Exception e)

  {

  out.println(e);

  }

  finally

  {

  widocRepEngine.close();

  engines.close();

  oEnterpriseSession.logoff();

  }

%>

</table>

</body>

</html>

<%!

private void getReportObjects(IEnterpriseSession oEnterpriseSession,ReportEngine widocRepEngine,int reportID, JspWriter out) throws Exception

{

DocumentInstance wiDoc = widocRepEngine.openDocument(reportID);

out.print("<TABLE BORDER=1>");

DataProviders dps=wiDoc.getDataProviders();

for(int b=0;b<dps.getCount();b++)

{

DataProvider dp=dps.getItem(b);

out.print("<TR><TD COLSPAN=2 BGCOLOR=KHAKI>Data Provider Name: " + dp.getName() + "</TD></TR>");

Query q=dp.getQuery();

  for(int a=0;a<q.getResultObjectCount() ;a++)

  {

  TreeNode tn=q.getResultObject(a).getParent();

  String name=q.getResultObject(a).getName();

  out.println("<tr><td>"+tn+"<b>/</b>"+name+"</td></tr>");

  }

}

out.print("</TABLE>");

wiDoc.closeDocument();

}

private void getReportObjectsInFolder(IEnterpriseSession oEnterpriseSession,ReportEngine widocRepEngine,int reportFolderID, JspWriter out) throws Exception

{

IInfoStore oInfoStore = (IInfoStore)oEnterpriseSession.getService("","InfoStore");

try

{

  String query = "select si_id from ci_infoobjects where SI_PARENTID="+reportFolderID;

  IInfoObjects oInfoObjects = oInfoStore.query(query);

  for(int i=0;i<oInfoObjects.size();i++)

  {

  IInfoObject oInfoObject = (IInfoObject) oInfoObjects.get(i);

  String objectKind1=oInfoObject.getKind();

  if(objectKind1.equals("Folder"))

  {

  int folderID=oInfoObject.getID();

  IInfoObjects boReportInfoObjects=oInfoStore.query("SELECT SI_ID FROM CI_INFOOBJECTS WHERE SI_PARENTID="+folderID);

  for(int j=0;j<boReportInfoObjects.size();j++)

  {

  IInfoObject boReportInfoObject=(IInfoObject)boReportInfoObjects.get(j);

  String objectKind=boReportInfoObject.getKind();

  if(objectKind.equals("Folder"))

  {

  getReportObjectsInFolder(oEnterpriseSession,widocRepEngine,boReportInfoObject.getID(),out);

  }

  else if(objectKind.equals("Webi"))

  {

  out.println("<h3><b>"+boReportInfoObject.getID()+"/"+boReportInfoObject.getTitle()+"</B></h3>");

  getReportObjects(oEnterpriseSession,widocRepEngine,boReportInfoObject.getID(),out);

  }

  }

  }

  else if(objectKind1.equals("Webi"))

  {

  out.println("<h3><b>"+oInfoObject.getID()+"/"+oInfoObject.getTitle()+"</B></h3>");

  getReportObjects(oEnterpriseSession,widocRepEngine,oInfoObject.getID(),out);

  }

  }

}

catch(Exception exe)

{

out.println(exe);

}

}

%>


6 Comments
Labels in this area