1299850 - How to add a saved data selection formula to a report using the Crystal Reports .NET inproc RAS SDK

SAP Knowledge Base Article - Public

1299850 - How to add a saved data selection formula to a report using the Crystal Reports .NET inproc RAS SDK

Symptom

How to add a saved data selection formula to a report using the Crystal Reports .NET inproc RAS SDK ?

Reproducing the Issue

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

    sample code:


                using CrystalDecisions.CrystalReports.Engine;

                using CrystalDecisions.ReportAppServer.Controllers;
                using CrystalDecisions.ReportAppServer.ClientDoc;
                using CrystalDecisions.ReportAppServer.DataDefModel;

                //CR Declarations
                ReportDocument                                                                                   m_boReportDocument;
                ISCDReportClientDocument                                                               m_boReportClientDocument;
           
                CrystalDecisions.ReportAppServer.DataDefModel.FormulaField  m_boFormula;


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

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

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

                //create a new Formula Object 
                m_boFormula = new CrystalDecisions.ReportAppServer.DataDefModel.FormulaField();

                //set it's properties
                m_boFormula.Text = "//Please enter your Formula here";
                m_boFormula.Text = "{Customer.City}='Berlin'";
                m_boFormula.Name = "//CustomerName";
                m_boFormula.Syntax = CrystalDecisions.ReportAppServer.DataDefModel.CrFormulaSyntaxEnum.crFormulaSyntaxCrystal;
                m_boFormula.Type = CrystalDecisions.ReportAppServer.DataDefModel.CrFieldValueTypeEnum.crFieldValueTypeStringField;

                //add to the report
                m_boReportClientDocument.DataDefController.SavedDataFilterController.SetFormulaText(m_boFormula.Text);

                //display in reportviewer
                crystalReportViewer1.ReportSource = m_boReportDocument;

    See Also

    • SAP Note 1285078 - How can I add a Database field using the Crystal Reports .NET inproc RAS SDK
    • SAP Note 1288988 - How to add a group to a report using the Crystal Reports .NET inproc RAS SDK
    • SAP Note 1298795 - How to add a record selection formula to a report using the Crystal Reports .NET inproc RAS SDK
    • SAP Note 1299289 - How to add a group selection formula to a report using the Crystal Reports .NET inproc RAS SDK

    Keywords

    How add saved data selection formula SF 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