1288051 - How to conditionally suppress a report area using the Crystal Reports .NET inproc RAS SDK

SAP Knowledge Base Article - Public

1288051 - How to conditionally suppress a report area using the Crystal Reports .NET inproc RAS SDK

Symptom

How to conditionally suppress a report area using the Crystal Reports .NET inproc RAS SDK?

Reproducing the Issue

  • .NET Visual Studio 2005
  • C#

Resolution

sample code:

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

       ReportDocument m_boReportDocument;
       ISCDReportClientDocument m_boReportClientDocument;

       CrystalDecisions.ReportAppServer.ReportDefModel.Section                   m_boSection;
       CrystalDecisions.ReportAppServer.ReportDefModel.ISCRArea               m_boRHArea;
       CrystalDecisions.ReportAppServer.ReportDefModel.ConditionFormula  m_boCond;
       CrystalDecisions.ReportAppServer.ReportDefModel.ISCRAreaFormat  m_boRHAreaFormat;


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

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

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

         // determine the section to add the subreport to - in this case the report header section
         m_boSection = m_boReportClientDocument.ReportDefController.ReportDefinition.ReportHeaderArea.Sections[0];

         m_boRHArea = m_boReportClientDocument.ReportDefController.ReportDefinition.ReportHeaderArea;
         m_boRHAreaFormat = m_boRHArea.Format; 

          // set the Conditions
          m_boCond = new CrystalDecisions.ReportAppServer.ReportDefModel.ConditionFormula();
          m_boCond.Text = "({Customer.Contact Title}='Miller')";
          m_boRHAreaFormat.ConditionFormulas.set_InternalItem(0, m_boCond);

          m_boReportClientDocument.ReportDefController.ReportAreaController.SetProperty(m_boRHArea, _
                                    CrystalDecisions.ReportAppServer.Controllers.CrReportAreaPropertyEnum.crReportAreaPropertyFormat, m_boRHAreaFormat);

            // show in reportviewer
            crystalReportViewer1.ReportSource = m_boReportDocument;

Keywords

How condition suppress report area .NET inproc RAS SDK , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

Product

Crystal Reports 2008 V1 ; SAP Crystal Reports XI R2 ; SAP Crystal Reports, developer version for Microsoft Visual Studio