Current Position:Home > Can not run complex report with ReportClientDocument using POJO beans.

Can not run complex report with ReportClientDocument using POJO beans.

Update:10-11Source: network consolidation
Advertisement
Hi All,
Any help would be very appreciated I have been stack on this issue for the last 4 hours.
My report has parameters, a ResultSet and subreports that themselves have both parameters and ResultSet.
The report runs well in Crystal Report Designer but not on my application with ReportClientDocument API.
The excpeiton I am getting is:
======================================================================
Caused by: java.lang.NullPointerException
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.sdk.occa.report.application.ParameterFieldController.do(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.sdk.occa.report.application.bs.a(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.sdk.occa.report.application.bs.byte(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.sdk.occa.report.application.a3.if(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.proxy.remoteagent.r.a(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.proxy.remoteagent.r.a(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.proxy.remoteagent.r.a(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.proxy.remoteagent.r.else(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.proxy.remoteagent.r.for(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.proxy.remoteagent.h.for(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.sdk.occa.report.application.cf.a(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.crystaldecisions.sdk.occa.report.application.DatabaseController.setDataSource(Unknown Source)
16:22:56,796 INFO  [STDOUT]      at com.tramada.documents.businessobjects.BODocumentProvider.generateDocument(BODocumentProvider.java:178)
16:22:56,796 INFO  [STDOUT]      at com.tramada.documents.service.impl.DocumentServiceImpl.generateDocumentContent(DocumentServiceImpl.java:125)
16:22:56,796 INFO  [STDOUT]      ... 58 more
This is my class that is trying to do the work.:
======================================================================
BODocumentProvider.java Created on 19/05/2008
This software is the confidential and proprietary information of Tramada
Systems Pty Limited.
package com.tramada.documents.businessobjects;
import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.Locale;
import com.businessobjects.samples.pojo.POJOResultSetFactory;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.occa.managedreports.IReportAppFactory;
import com.crystaldecisions.sdk.occa.report.application.ISubreportClientDocument;
import com.crystaldecisions.sdk.occa.report.application.ParameterFieldController;
import com.crystaldecisions.sdk.occa.report.application.ReportClientDocument;
import com.crystaldecisions.sdk.occa.report.application.SubreportController;
import com.crystaldecisions.sdk.occa.report.data.Fields;
import com.crystaldecisions.sdk.occa.report.data.IField;
import com.crystaldecisions.sdk.occa.report.data.ITable;
import com.crystaldecisions.sdk.occa.report.data.Tables;
import com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat;
import com.crystaldecisions.sdk.occa.report.lib.IStrings;
import com.tramada.core.utils.SoftMap;
import com.tramada.documents.DocumentDataProvider;
import com.tramada.documents.DocumentDescriptor;
import com.tramada.documents.DocumentFormat;
import com.tramada.documents.DocumentProvider;
import com.tramada.documents.SubDocumentDescriptor;
import com.tramada.documents.businessobjects.model.Template;
import com.tramada.documents.model.DocumentContent;
import com.tramada.persistence.home.GenericHome;
Business Objects specific Document Provider.
public class BODocumentProvider implements DocumentProvider {
    private static final String BO_AUTH_TYPE = "secEnterprise";
    private boolean connect;
    private String userName;
    private String userPassword;
    private String boURL;
    private String documentsFolder;
    private GenericHome home;
Local cache. Keeps track of document source for better performance.
    private SoftMap<String, ReportClientDocument> cachedSources = new SoftMap<String, ReportClientDocument>();
    // SETTERS & GETTERS
    // SETTERS & GETTERS
    public GenericHome getHome() {
        return home;
    public void setHome(GenericHome home) {
        this.home = home;
    public boolean getConnect() {
        return connect;
    public void setConnect(boolean connect) {
        this.connect = connect;
    public String getBoURL() {
        return boURL;
    public void setBoURL(String boURL) {
        this.boURL = boURL;
    public String getUserName() {
        return userName;
    public void setUserName(String userName) {
        this.userName = userName;
    public String getUserPassword() {
        return userPassword;
    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    public String getDocumentsFolder() {
        return documentsFolder;
    public void setDocumentsFolder(String documentsFolder) {
        this.documentsFolder = documentsFolder;
    // PUBLIC INTERFACE
Generates a document given its descriptor.
@param descriptor
           valid document descriptor
@return Document (generated document).
    public DocumentContent generateDocument(DocumentDescriptor descriptor, DocumentFormat format) throws Exception {
        if (descriptor == null) {
            throw new IllegalArgumentException("descriptor==null");
        if (format == null) {
            throw new IllegalArgumentException("format==null");
        // get the document source.
        // Can not use setDataSource() error code 2147483648?
        ReportClientDocument document = getDocument(descriptor.getDocumentName());
        ParameterFieldController parameterController = document.getDataDefController().getParameterFieldController();
        // insert the main document parameters and there values
        populateParameters(document.getDataDefController().getDataDefinition().getParameterFields(),
                parameterController, descriptor, "");
        // insert into the main document all the required data.
        Tables tables = document.getDatabaseController().getDatabase().getTables();
        for (int i = 0; i < tables.size(); i++) {
            ITable table = tables.getTable(i);
            String tableAlias = table.getAlias();
            DocumentDataProvider provider = descriptor.getDocumentDataProvider(tableAlias);
            POJOResultSetFactory factory = new POJOResultSetFactory(provider.getDataType());
            document.getDatabaseController().setDataSource(factory.createResultSet(provider.getData()), tableAlias,
                    tableAlias);
        // go through all the sub-documents and do the same thing as for the
        // main document.
        SubreportController subReportController = document.getSubreportController();
        IStrings names = subReportController.getSubreportNames();
        for (int i = 0; i < names.size(); i++) {
            String subDocumentName = (String) names.get(i);
            SubDocumentDescriptor subDescriptor = descriptor.getSubDocument(subDocumentName);
            // get the actual sub document.
            ISubreportClientDocument subDocument = subReportController.getSubreport(subDocumentName);
            // insert the subdocument parameters.
            populateParameters(subDocument.getDataDefController().getDataDefinition().getParameterFields(),
                    parameterController, subDescriptor, subDocumentName);
            // insert into the main document all the required data.
            Tables subTables = subDocument.getDatabaseController().getDatabase().getTables();
            for (int j = 0; j < subTables.size(); j++) {
                ITable subTable = subTables.getTable(j);
                String tableAlias = subTable.getAlias();
                DocumentDataProvider subProvider = subDescriptor.getDocumentDataProvider(tableAlias);
                POJOResultSetFactory subFactory = new POJOResultSetFactory(subProvider.getDataType());
                subDocument.getDatabaseController().setDataSource(subFactory.createResultSet(subProvider.getData()),
                        tableAlias, tableAlias);
        // generate the report in the specified format
        ByteArrayInputStream bais = (ByteArrayInputStream) document.getPrintOutputController().export(
                getReportFormat(format));
        byte[] content = new byte[bais.available()];
        bais.read(content);
        return (new DocumentContent(content));
Refreshes the connector and all its cached document sources.
    public void refresh() throws Exception {
        cachedSources.clear();
    // PRIVATE ROUTINES
Populates the document parameters with there values.
    private void populateParameters(Fields parameters, ParameterFieldController controller,
            DocumentDescriptor descriptor, String documentName) throws Exception {
        for (int i = 0; i < parameters.size(); i++) {
            IField parameter = parameters.getField(i);
            String parameterName = parameter.getName();
            if (!descriptor.getParameters().containsKey(parameterName)) {
                throw new IllegalStateException("missing parameter entry for '" + parameterName + "'");
            Object value = descriptor.getParameter(parameterName);
            if (value != null) {
                controller.setCurrentValue(documentName, parameterName, value);
Retrieves the document source. If the source is not cached get it from
BO. First get the template name that is stored on BO.
    private ReportClientDocument getDocument(String documentName) throws Exception {
        ReportClientDocument source = cachedSources.get(documentName);
        if (source == null) {
            String templateName = getTemplateName(documentName);
            if (userName == null) {
                throw new IllegalArgumentException("user-name==null");
            if (userPassword == null) {
                throw new IllegalArgumentException("user-password==null");
            if (boURL == null) {
                throw new IllegalArgumentException("boURL==null");
            if (documentsFolder == null) {
                throw new IllegalArgumentException("documents-folder==null");
            // login to BO
            IEnterpriseSession enterpriseSession = CrystalEnterprise.getSessionMgr().logon(userName, userPassword,
                    boURL, BO_AUTH_TYPE);
            IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore");
            // get the application folder.
            IInfoObjects folders = iStore.query("Select SI_ID From CI_INFOOBJECTS Where SI_PROGID='CrystalEnterprise.Folder' And SI_NAME = '"
                    + documentsFolder + "'");
            if (folders.size() != 1) {
                throw new IllegalStateException("documents folder '" + documentsFolder + "' not found on BO Server '"
                        + boURL + "'.");
            IInfoObject folder = (IInfoObject) folders.get(0);
            // get the document identified by the template name.
            IInfoObjects templates = iStore.query("select SI_ID, SI_NAME From CI_INFOOBJECTS "
                    + "where SI_PROGID = 'CrystalEnterprise.Report' " + "And SI_INSTANCE_OBJECT = 0 "
                    + "And SI_PARENT_FOLDER = " + folder.getID() + " And SI_NAME= '" + templateName + "'");
            if (templates.size() != 1) {
                throw new IllegalStateException("template with name '" + templateName + "' not found in folder '"
                        + documentsFolder + "'on BO Server '" + boURL + "'.");
            source = ((IReportAppFactory) enterpriseSession.getService("RASReportFactory")).openDocument(
                    ((IInfoObject) templates.get(0)).getID(), 0, Locale.getDefault());
            cachedSources.put(documentName, source);
        return (source);
Returns the associated template name for the given document descriptor.
    @SuppressWarnings("unchecked")
    private String getTemplateName(String documentName) {
        Template example = new Template();
        example.setDocumentName(documentName);
        List<Template> templates = (List<Template>) home.findByExampleExcludingAssociations(example);
        if (templates == null || templates.size() != 1) {
            throw new IllegalStateException("no template defined for document name '" + documentName + "'");
        return (templates.get(0).getTemplateName());
Get the equivalent BO format for the given document format.
@param format
           document format.
@return ReportExportFormat
    private ReportExportFormat getReportFormat(DocumentFormat format) {
        if (format.equals(DocumentFormat.PDF)) {
            return (ReportExportFormat.PDF);
        } else if (format.equals(DocumentFormat.WORD)) {
            return (ReportExportFormat.MSWord);
        } else if (format.equals(DocumentFormat.EXCEL)) {
            return (ReportExportFormat.MSExcel);
        return (ReportExportFormat.MSWord);
Best Regards
Khalef  Bessaih

The Best Answer

Advertisement
Hello,
If I understand correctly, you create a local report which choose report from Report Server. You have two query parameters in the report which are returned by stored procedure. Currently, you cannot get default values for these parameters when run the report.
Based on my test, if we haven’t configure these parameter with Available Values, we can reproduce the same issue. Also, caching issue may cause the same issue. If the issue is persist, please delete the corresponding report in the report server. Then, redeploy
it to check.
There is a similar issue, you can refer to it.
http://social.msdn.microsoft.com/Forums/en-US/6a548d65-35d0-4a3e-8b64-3b7b655c76ee/ssrs-2008-report-parameter-default-value-doesnt-work-when-deployed
Regards,
Alisa Tang
Alisa Tang
TechNet Community Support
  • Can not run complex report with ReportClientDocument using POJO beans. Update:10-11

    Hi All, Any help would be very appreciated I have been stack on this issue for the last 4 hours. My report has parameters, a ResultSet and subreports that themselves have both parameters and ResultSet. The report runs well in Crystal Report Designer

  • How to run a report out of the web container? Update:11-30

    Hi All, <p> Does anyone have tips on running a report outside of the web container?  I'd like to be able to JUnit the scenarios I'm coding up without having an app server running.  What is the ReportClientDocument expecting in the request, response,

  • FR Studio moving Cells Issue when running the report in Workspace Update:11-30

    I've created a complex, multi-grid FR report. There are 8 grids and 2 database connections in the report. When I run the report in Workspace for a smaller entity/unit, the report looks fine in PDF. When I run the report for a larger entity/unit, one

  • Speed Issue of Running ICP Reports Update:11-30

    Dear HFM Professionals, Have anyone encountered ICP Report running too slow? In our case, it took 5 to 40 min, is that normal? Here are our specs: CPU: E5450 3.0GHz*2 RAM: 24G Entity Dimension involving ICP: around 135 Account Dimension involving ICP

  • Layout errors when running 6i Reports on Solaris Update:11-30

    Hi, I've developed a large number of complex reports - lots of nested groups etc. They were developed on NT in Rep 6i patch 8. They run fine in Reports Runtime on NT. When I ftp them across to the Solaris box and compile them in rw60con they no longe

  • Error while running a report Update:10-11

    Hi all, I am getting this particular error while running a report. The error is: <b>SQL Error: 604 System error in program SAPLRRK0 and form RSRDR;SRRK0F30-01- Diagnosis This internal error is a targeted termination since the program has an incorrec

  • To pass new session variable value to stored proc before running a report. Update:10-11

    Hi, Below is summary of the report requirement - Database level design 1. Created a view and a global temporary table (GTT) 2. Created an Oracle package procedure to accept from and to business dates on basis of which it will fetch, process and popul

  • SQL Error while running a report Update:10-11

    Hi Experts, I am getting an error like below while running a report for particular sales Organization and Company code combination *SQL Error: 83-* *SQL0083C A memory allocation error has occured* *Errors occured during parellel processing of query 3

  • Error while running the Report Update:10-11

    Hi , I am trying to run the Report in Bex Analyzer. and once I enter the value for the variable, it gives me message that "Element is not correctly define (please check query)" and when i click on the error it gives me detail message as below :

  • Error while running a report JSP in a war file from 9iAS server Update:10-11

    Hi, I've a web application archive file (war) which i m deploying to the web using OEM. The war file consists of many JSPs. Among those JSPs i have one Report JSP, which i m calling from another JSP which is like a parameter form for the report JSP.