This document provides a way to get the data objects used in a web intelligence document using Report Engine Java SDK.

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:

http://scn.sap.com/people/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


Get Webi Document Objects

<html>

<style>

.table {

  margin-bottom: 15px;

  border-collapse: collapse;

  }

  .table_header td {

  background: #294f7f;

  padding: 5px 10px;

  color: rgb(255,255,255);

  border-top: 1px solid #CBD6DE;

  border-bottom: 1px solid #ADBECB;

  font-size: 1.0em;

  font-weight: bold;

  }

  .table_header td {

  border: 1px solid #CBD6DE;

  }

  .row td{

  padding: 5px 10px;

  color: #666666;

  border: 1px solid #CBD6DE;

  }

  .row td {

  background: #ffffff;

  }

</style>

</head>

<body>

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

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

             com.businessobjects.rebean.wi.*,

  java.io.*”

%>

<TABLE id=”htmlTable” BORDER=”1″ cellpadding=”0″ cellspacing=”0″   width=”90%”  class=”table” align=”center”>

<tr class=”table_header”>

   <td>Report ID</td><td>Report Name</td><td>Report Objects</td>

                               

                </tr>

<%

  //Enter Username

  String username = “administrator”;

  //Enter User password

  String password = “”;

  //Enter CMS Name

  String cmsname = “localhost:6400”;

  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);

  ReportDictionary reportDictionary=wiDoc.getDictionary();

  for(int a=0;a<reportDictionary.getChildCount() ;a++)

  {

  String name=reportDictionary.getChildAt(a).getName();

  out.println(“<td>”+name+”</td></tr>”);

  out.println(“<tr class=\”row\”><td>  </td><td>  </td>”);

  }

  out.println(“<td></td></tr>”);

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(“<tr class=\”row\”><td>”+ boReportInfoObject.getID() + “</td><td>”+ boReportInfoObject.getTitle() + “</td>”);

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

  }

  }

  }

  else if(objectKind1.equals(“Webi”))

  {

  out.println(“<tr class=\”row\”><td>”+ oInfoObject.getID() + “</td><td>”+ oInfoObject.getTitle() + “</td>”);

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

  }

  }

}

catch(Exception exe)

{

out.println(exe);

}

}

%>


To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Shivam Kumar

    Hi Prithviraj,

    Can you please help me in creating a similar script for BI 4.1? I need it really badly. If you could just guide me what needs to be changed here to make it work with BI 4.1, it would be great.

    Thanks,

    Shivam

    (0) 
    1. Dell Stinnett-Christy

      None of this coed will work with 4.1 – the ReportEngine SDK has been deprecated.  Instead, you need to look at the new RESTful Web Services SDK to get this information.  The beauty of the RESTful Web Services SDK is that you don’t have to install anything from SAP to use it – you just have to have an HTTP components library (I use the one from Apache).  RWS communicates through HTTP Get and Post calls and returns data in either XML or JSON format. 

      For more info about RWS, you can get the Help files from http://help.sap.com/bobip.  Select the version of BO that you have on the left and then go to the Development Information section.  There is also and SCN space for it at RESTful Web Services SDK.

      -Dell

      (0) 

Leave a Reply