Crystal Reports for Eclipse Developer Guide

To add a database field to a report

  1. Retrieve the database tables from the report, and get the first field from the first table.
      Tables tables = clientDoc.getDatabase().getTables();
      IField firstField = tables.getTable(0).getDataFields().getField(0);
    
  2. Create a new field object and set the FieldValueType and DataSource properties based on the first field retrieved.
      FieldObject fieldObject = new FieldObject();
      fieldObject.setFieldValueType(firstField.getType());
      fieldObject.setDataSource(firstField.getFormulaForm());
    
  3. Set formatting options for the FieldObject.
      fieldObject.setLeft(1000);
    
  4. Using the ReportDefController object, find the section of the report that the FieldObject will be added to
      ReportDefController reportDefController = clientDoc.getReportDefController();
      ISection section = reportDefController.getReportDefinition().getPageHeaderArea().getSections().getSection(0);
    
  5. Add the FieldObject to a section in the report using the ReportDefController object.
      reportDefController.getReportObjectController().add(fieldObject, section, 0);
    
Example: 
This sample adds a single database field to the page header of a report.
void AddDatabaseField(ReportClientDocument clientDoc)
{
  Tables tables = clientDoc.getDatabase().getTables();
  IField firstField = tables.getTable(0).getDataFields().getField(0);

  FieldObject fieldObject = new FieldObject();
  fieldObject.setFieldValueType(firstField.getType());
  fieldObject.setDataSource(firstField.getFormulaForm());

  fieldObject.setLeft(1000);

  ReportDefController reportDefController = clientDoc.getReportDefController();
  ISection section = reportDefController.getReportDefinition().getPageHeaderArea().getSections().getSection(0);

  reportDefController.getReportObjectController().add(fieldObject, section, 0);
}



SAP BusinessObjects
http://www.sap.com/sapbusinessobjects/
Support services
http://service.sap.com/bosap-support/
Product Documentation on the Web
http://help.sap.com/