SAP Knowledge Base Article - Public

1306846 - How to add a subreport to a report using the Crystal Reports .NET inproc RAS SDK

Symptom

How to add a subreport to a report using the Crystal Reports .NET inproc RAS SDK ?

Reproducing the Issue

  • Crystal Reports XI Release 2 Service Pack 2 and later 
  • C#
  • Resolution

    sample code:


               using CrystalDecisions.CrystalReports.Engine;
               using CrystalDecisions.ReportAppServer.ClientDoc;
                          

                //CR Declarations
                ReportDocument                                                                                                                             m_boReportDocument;
                ISCDReportClientDocument                                                                                                         m_boReportClientDocument;

                CrystalDecisions.ReportAppServer.ReportDefModel.Section                                                 m_boSection;
                CrystalDecisions.ReportAppServer.Controllers.SubreportClientDocument                           m_boSubreportClientDocument;

                 //create a new ReportDocument
                m_boReportDocument = new ReportDocument();

                //load the RPT file
                m_boReportDocument.Load("..\\..\\DummyReport.rpt");

                //access the ReportClientDocument in the ReportDocument (EROM bridge)
                m_boReportClientDocument = m_boReportDocument.ReportClientDocument;

                //first determine the area to add the subreport to - in this case the report header area
                m_boSection = m_boReportClientDocument.ReportDefController.ReportDefinition.ReportHeaderArea.Sections[0];
               
                //when adding a new subreport (as opposed to importing), you need to leave the ReportURL property blank
                m_boSubreportClientDocument = m_boReportClientDocument.SubreportController.ImportSubreport("testSub", "", m_boSection);
                
                //if you try to add a sub-report to a section that is smaller than the dimensions you give the sub-report, you will get an error of
                //"Invalid section height" error when you try to add sub-report links to the sub-report database tables.
                //display in reportviewer
                crystalReportViewer1.ReportSource = m_boReportDocument;

    See Also

  • SAP Note 1288988 - How to add a group to a report using the Crystal Reports .NET inproc RAS SDK
  • SAP Note 1306234 - How to add a box to a report using the Crystal Reports .NET inproc RAS SDK
  • SAP Note 1306326 - How to add a summaryfield to a report using the Crystal Reports .NET inproc RAS SDK
  • SAP Note 1306320 - How to add a tooltip to a report using the Crystal Reports .NET inproc RAS SDK
  • SAP Note 1306531 - How to add a text object to a report using the Crystal Reports .NET inproc RAS SDK  
  • Keywords

    How add subreport report Crystal Reports .NET inproc RAS SDK , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

    Product

    SAP Crystal Reports XI R2