1285078 - How can I add a Database field using the Crystal Reports .NET inproc RAS SDK

SAP Knowledge Base Articles - public

1285078 - How can I add a Database field using the Crystal Reports .NET inproc RAS SDK


How can I add a Database field using the Crystal Reports .NET inproc RAS SDK

Reproducing the Issue

.NET Visual Studio 2005


How can I add a Database field using the Crystal Reports .NET inproc RAS SDK:

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

        // CR Declarations
        ReportDocument boReportDocument;
        ISCDReportClientDocument boReportClientDocument;

        CrystalDecisions.ReportAppServer.ReportDefModel.Section       m_boSection;
        CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject m_boFieldObject;

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

          // load the RPT file 

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

           //Get the first section in the details section
           m_boSection = m_boReportClientDocument.ReportDefController.ReportDefinition.DetailArea.Sections[0];

            /Create the field object that we will add to the report and set all of its properties
           m_boFieldObject = new CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject();
            //Set which field to use for the data to be displayed
            m_boFieldObject.DataSourceName = "{Customer.City}";
            m_boFieldObject.FieldValueType = CrystalDecisions.ReportAppServer.DataDefModel.CrFieldValueTypeEnum.crFieldValueTypeStringField;
            m_boFieldObject.Left = 4 * 1440; //1440 twips per inch
            m_boFieldObject.Width = 3 * 1440;
            m_boFieldObject.FontColor = new CrystalDecisions.ReportAppServer.ReportDefModel.FontColor();
            m_boFieldObject.FontColor.Font.Name = "Arial";
            m_boFieldObject.FontColor.Font.Size = 10;
            m_boFieldObject.Format.HorizontalAlignment = CrystalDecisions.ReportAppServer.ReportDefModel.CrAlignmentEnum.crAlignmentLeft;
            //Add the object to the report
            boReportClientDocument.ReportDefController.ReportObjectController.Add(boFieldObject, boSection, -1);

            // show in reportviewer
            crystalReportViewer1.ReportSource = m_boReportDocument;

Prior to the release of Crystal Reports XI R2 Service Pack 2, report modification was only possible using the RAS (Report Application Server) SDK with a RAS server or by using In-Process RAS with the purchase of additional licensing.
Using Crystal Reports  XI R2 Service Pack 2 and higher, you can now access the report modification APIs without any additional licensing by using the inprocess-RAS engine through the Crystal Reports .NET SDK. An example of accessing the RAS SDK through the Crystal Reports  .NET SDK is as follows:


See Also



RAS, Modification, In-Process, .NET, Create, Add, Remove, Change, Modify, ReportClientDocument, inproc, DBField, database field  , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To


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