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:

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


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

}

}

%>


To report this post you need to login first.

6 Comments

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

  1. Preethi M

    Hi Prithviraj,

    can you please provide a sample code to get class definition of objects used in webi report for BO 4.1.

    I found a solution to get list of Objects used in webi report using Restful webservice SDK. But i would like to find out the class where these object belongs to.

    Please let me know ,how to find class name of object in Restful webserce SDK in BO 4.1

    Thanks,

    Preethi

    (0) 
    1. Dell Stinnett-Christy

      There is no way to do this with just the Webi RESTful SDK.  So, you have two options for this – one requires getting universe information from the Semantic Layer RESTful SDK and the other requires getting it form the Java Semantic Layer SDK.  Basically, in either one, you have to walk down the class tree and get the ID code for the classes and their objects.

      Personally, I would create a class to store the following info from the Semantic Layer:

      Class ID

      Class Name

      Object ID

      Object Name

      Object Type (Dimension, Measure, Attribute)

      And I might store it in a HashMap using the Object ID as the key to make it easy to find when I’m walking through the report.

      From there, the object ID code will match the ID code from the report and from there you can get the class. 

      -Dell

      (0) 
      1. Preethi M

        Hi Dell,

        In BO 4.1 i used ReportDictionaryHelper.getDictionaryObjectsFlatList method of Restful webservice SDK to get objects list.

        But its listing all objects of data providers in the webi report.(if an object is used in many data providers,the object list has that many duplicate objects)

        Is there a way to get objects of each data provider seperately or how to recognize the dataprovider of objects?

        Thanks and Regards,

        Preethi

        (0) 
        1. Dell Stinnett-Christy

          You would have to walk through each data provider – which is possible using the RESTful SDK.  In the Webi & Semantic Layer RESTful SDK help, specifically look for the section on “Data Provider URLs” to get the list of data providers in a document and details of each data provider, which will give you the list of universe objects that are used in a data provider.

          -Dell

          (0) 

Leave a Reply