Crystal Reports for Eclipse Developer Guide

To add a parameter field to a report

  1. Create a new parameter field.
      IParameterField parameterField = new ParameterField();
  2. Set the parameter field name, and description.
       parameterField.setName("NewParameter");
       parameterField.setDescription("discrete string parameter description");
    
  3. Set the type of parameter.

    Note: Not all types may be used for parameter fields. For example, you may not set Type to 20 (Bitmap). Use the isValidType method in the ParameterFieldController class to determine if a certain type is valid for a parameter field.
       parameterField.setValueRangeKind(ParameterValueRangeKind.discrete);
       parameterField.setParameterType(ParameterFieldType.queryParameter);
       parameterField.setType(FieldValueType.numberField);
    
  4. Set what values are allowed in the parameter field.

    Note: Not all types may be used for parameter fields. For example, you may not set Type to 20 (Bitmap). Use the isValidType method in the ParameterFieldController class to determine if a certain type is valid for a parameter field.
       parameterField.setAllowCustomCurrentValues(false);
       parameterField.setAllowMultiValue(false);
       parameterField.setAllowNullValue(false);
    
  5. Add the parameter to the report using the ParameterFieldController class.

    Note: When a parameter is added using the ParameterFieldController class, it is not placed on the report, and the user will not be prompted when the report is refreshed. To use the parameter field to prompt a user, the parameter must be used in a filter, or must be added using the ResultFieldController class.
      rcd.getDataDefController().getParameterFieldController().add(parameterField);
Example: 
The following example defines a new, discrete, number parameter and adds it using the ParameterFieldController:
void add_parameter_field(ReportClientDocument rcd)
{
   IParameterField parameterField = new ParameterField();
   parameterField.setName("NewParameter");
   parameterField.setDescription("discrete string parameter description");
   parameterField.setValueRangeKind(ParameterValueRangeKind.discrete);
   parameterField.setParameterType(ParameterFieldType.queryParameter);
   parameterField.setType(FieldValueType.numberField);
   parameterField.setAllowCustomCurrentValues(false);
   parameterField.setAllowMultiValue(false);
   parameterField.setAllowNullValue(false);
   rcd.getDataDefController().getParameterFieldController().add(parameterField);
}



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