Quantcast
Channel: SCN : Document List - Java SDK Application Development
Viewing all articles
Browse latest Browse all 39

Java Enterprise BE14 List Reports used in a Publication

$
0
0

This document provides a way to retrieve the details of documents included in a publication using Business Intelligence platform Java SDK. The sample code lists all the documents associated with a publication and display the output in a browser window.

 

Warning

The code given below can be very destructive if not used properly.  Please ensure that you have made a backup of your CMS database and your Input and Output FRS prior to running any code.

 

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 to retrieve details of documents (source document (s) + dynamic recipient document) included in a publication

 

Notes:

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

• I sample code is tested with BI 4.0 version of SAP BusinessObjects Platform.


<%@ page import="com.businessobjects.sdk.plugin.desktop.publication.*,             com.crystaldecisions.sdk.occa.infostore.*,            com.crystaldecisions.sdk.framework.*,             com.crystaldecisions.sdk.plugin.CeKind,          java.util.*"
%><%          // Retrieve the logon information (this was entered on the index.html page).    String userName = "username";    String password = "password";    String cmsName = "cmsname";    String authType = "secEnterprise";    // Retrieve the publication name that is to be updated with dynamic recipients from    // the specified Crystal Report.  Also retrieve the Crystal Report name that is being    // used as the source of the dynamic recipients (these were entered on the index.html page).    String publicationName = "publication Name";
%><%        ISessionMgr boSessionMgr = null;    IEnterpriseSession boEnterpriseSession = null;           // Initialize the Session Manager by getting it from the Crystal Enterprise class's          // getSessionMgr function.          boSessionMgr = CrystalEnterprise.getSessionMgr();          // Logon to the Session Manager to create a new BOE session.  Pass in the user name, password,          // the CMS name, and the authentication type.          boEnterpriseSession = boSessionMgr.logon(userName, password, cmsName, authType);
%><%          // Business Objects Declarations.    IInfoStore boInfoStore = null;    IInfoObjects boPublicationInfoObjects = null;    IInfoObject boPublicationInfoObject = null;    IPublicationEventHandlers boPublicationEventHandlers = null;    IPublicationEventHandler boPublicationEventHandler = null;    IPublicationEventHandlerInfo boPublicationEventHandlerInfo = null;

try 
{    
//Retrieve the InfoStore object.    
boInfoStore = (IInfoStore) boEnterpriseSession.getService("", "InfoStore");        
 // Retrieve the desired publication.    
boPublicationInfoObjects = boInfoStore.query("SELECT * FROM CI_INFOOBJECTS WHERE SI_KIND = '" + CeKind.PUBLICATION + "' AND SI_NAME = '" + publicationName + "' AND SI_INSTANCE = 0");    
boPublicationInfoObject = (IInfoObject) boPublicationInfoObjects.get(0);         
// Cast the publication infoObject to IPublication.    
IPublication boPublication = (IPublication)boPublicationInfoObject; 
out.println("<b>Publication Name: </b>" + boPublicationInfoObject.getTitle() +"<br><br>");  
Collection collection= boPublication.getDocuments();
Iterator iterator = collection.iterator();     
out.println("<b>SourceDocument Info </b><br><br>");      while (iterator.hasNext()){
Object data = iterator.next();
String data1=(String)data.toString();
IInfoObjects sourceobjects= (IInfoObjects)boInfoStore.query("SELECT * FROM CI_INFOOBJECTS WHERE SI_ID="+ data);
IInfoObject sourceobject=  (IInfoObject)sourceobjects.get(0);          out.println("<b> Report Name: </b>" + sourceobject.getTitle() + "<br>");          out.println("<b> Report CUID: </b>" + sourceobject.getCUID()+ "<br><br>");      }
boPublicationEventHandlers = boPublication.getPublicationEventHandlers();
boPublicationEventHandler = boPublicationEventHandlers.getPublicationEventHandler(CePropertyID.SI_ON_READ_RECIPIENTS);   // Trigger when publication reads the list of recipients   
out.println("<b>Dynamic Recipients Document Info </b><br><br>");
if(boPublicationEventHandler.size()==0 )
{
out.println("The publication " + boPublicationInfoObject.getTitle() + " has zero dynamic recipients" );
}
else
{
boPublicationEventHandlerInfo  = (IPublicationEventHandlerInfo)boPublicationEventHandler.get(0);
IInfoObjects dynamicdocinfos = boInfoStore.query("SELECT * FROM CI_INFOOBJECTS WHERE SI_ID="+boPublicationEventHandlerInfo.getDynamicDataDocumentID());
IInfoObject  dynamicdocinfo= (IInfoObject) dynamicdocinfos.get(0);
out.println("<b> Report Name: </b>" + dynamicdocinfo.getTitle() + "<br>");
out.println("<b> Report Kind: </b>" + dynamicdocinfo.getKind() + "<br>");
out.println("<b>Report CUID: </b>" + dynamicdocinfo.getCUID() + "<br><br>");  
} 
}catch (Exception ex) {                      out.println(ex);            } finally {                    // Ensure clean-up of the Enterprise session              if(boEnterpriseSession != null) {                  try {                      boEnterpriseSession.logoff();                  } catch(Exception e_ignore_in_cleanup) {}              }           }
%>

Viewing all articles
Browse latest Browse all 39

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>