New, managed reports can be created in an
Enterprise repository using the
IReportAppFactory.newDocument
method. You must logon to an Enterprise session using the classes contained in
the SAP BusinessObjects Business Intelligence platform 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.
Note: Do not use the
ReportClientDocument.newDocument
method, which is reserved for creating new, unmanaged reports on a file path
accessible to a RAS server.
Logon to an Enterprise server to
create an active Enterprise session.
ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
IEnterpriseSession enterpriseSession = sessionMgr.logon("username", "password", "hostname:port", "secEnterprise"); Call the
getService
method of the
IEnterpriseSession interface to
establish a connection with the RAS server.
IReportAppFactory reportAppFactory = (IReportAppFactory) enterpriseSession.getService("RASReportFactory"); Call the
newDocument method of the
IReportAppFactory class to
create a new, blank report.
ReportClientDocument rcd = reportAppFactory.newDocument(java.util.Locale.ENGLISH);
Query the Enterprise repository for
a folder.
This query returns a
folder named
My Reports. The
result of the query stores the folder as an
InfoObject
object.
IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore");
IInfoObjects objects = iStore.query("Select SI_ID From CI_INFOOBJECTS Where SI_NAME='My Reports' And SI_INSTANCE=0");
IInfoObject folder = (IInfoObject)objects.get(0); Save your new, blank report to the
folder in the Enterprise repository and close the report.
rcd.saveAs("MyReport", folder.getID(), ReportSaveAsOptions._overwriteExisting);
rcd.close();
Example:
The following code creates a new, blank, managed
report called
MyNewReport.rpt in an Enterprise
repository.
void createNewManagedReport() throws SDKException, ReportSDKException, IOException
{
ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
IEnterpriseSession enterpriseSession = sessionMgr.logon("username", "password", "hostname:port", "secEnterprise");
IReportAppFactory reportAppFactory = (IReportAppFactory) enterpriseSession.getService("RASReportFactory");
ReportClientDocument rcd = reportAppFactory.newDocument(java.util.Locale.ENGLISH);
IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore");
IInfoObjects objects = iStore.query("Select SI_ID From CI_INFOOBJECTS Where SI_NAME='My Reports' And SI_INSTANCE=0");
IInfoObject folder = (IInfoObject)objects.get(0);
rcd.saveAs("MyReport", folder.getID(), ReportSaveAsOptions._overwriteExisting);
rcd.close();
}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.ReportClientDocument
com.crystaldecisions.sdk.occa.report.application.ReportSaveAsOptions
com.crystaldecisions.sdk.occa.report.lib.ReportSDKException
java.io.IOException
After creating a new, blank report, the report
can be further modified to establish a data source connection, add tables and
table links, and design the layout.