To open a managed report

Managed reports can be opened from an Enterprise repository and stored as a ReportClientDocument object. You must logon to an Enterprise session and query for the report object using the classes contained in the SAP BusinessObjects Business Intelligence platform Java SDK. To learn about best practices when logging on to an Enterprise server, and how to use the query language to select objects from the repository, see the SAP BusinessObjects Business Intelligence Platform Java SDK Developer Guide.
  1. Logon to an Enterprise server to create an active Enterprise session.
    ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
    IEnterpriseSession enterpriseSession = sessionMgr.logon("username", "password", "hostname:port", "secEnterprise");
  2. Query the Enterprise repository for a report.
    The result of the query stores the report as an InfoObject object.
    IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore");
    IInfoObjects reports = iStore.query("Select SI_ID From CI_INFOOBJECTS Where SI_NAME='World Sales Report' And SI_INSTANCE=0");
    IInfoObject report = (IInfoObject)reports.get(0);
  3. Call the getService method of the IEnterpriseSession interface to establish a connection with the RAS server.
    IReportAppFactory reportAppFactory = (IReportAppFactory) enterpriseSession.getService("RASReportFactory");
  4. Call the openDocument method of the IReportAppFactory interface to open the report.
    The InfoObject that stored the report from the repository query is passed as the first argument to the openDocument method. The second parameter accepts an integer value that specifies the open options. See the OpenReportOptions class for details.
    ReportClientDocument rcd = reportAppFactory.openDocument(report, OpenReportOptions._openAsReadOnly, java.util.Locale.US);
A ReportClientDocument object is created that represents the report, and can be modified using the controllers in this class.
Example: 
The following code opens a managed report called World Sales Report.rpt from a repository.
ReportClientDocument openManagedReport() throws SDKException
{
    ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
    IEnterpriseSession enterpriseSession = sessionMgr.logon("username", "password", "hostname:port", "secEnterprise");    
    IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore");
    IInfoObjects reports = iStore.query("Select SI_ID From CI_INFOOBJECTS Where SI_NAME='World Sales Report' And SI_INSTANCE=0");   
    IInfoObject report = (IInfoObject)reports.get(0);     
                
    IReportAppFactory reportAppFactory = (IReportAppFactory) enterpriseSession.getService("RASReportFactory");
    ReportClientDocument rcd = reportAppFactory.openDocument(report, OpenReportOptions._openAsReadOnly, java.util.Locale.US);
    return rcd;
}
This list includes the classes used by the sample code:
  • com.crystaldecisions.sdk.exception.SDKException
  • com.crystaldecisions.sdk.framework.CrystalEnterprise
  • com.crystaldecisions.sdk.framework.IEnterpriseSession
  • com.crystaldecisions.sdk.framework.ISessionMgr
  • com.crystaldecisions.sdk.occa.infostore.IInfoObject
  • com.crystaldecisions.sdk.occa.infostore.IInfoObjects
  • com.crystaldecisions.sdk.occa.infostore.IInfoStore
  • com.crystaldecisions.sdk.occa.managedreports.IReportAppFactory
  • com.crystaldecisions.sdk.occa.report.application.OpenReportOptions
  • com.crystaldecisions.sdk.occa.report.application.ReportClientDocument