SAP Knowledge Base Article - Public

1183956 - Error: "Invalid Column Name 'NULL'" in the JRC when using a command object with a parameter and changing the database location at runtime

Symptom

When using a command object with a parameter and changing the database location at runtime, the JRC throws the following error message:

"Invalid Column Name 'NULL'"

Steps to Reproduce

In Crystal Reports, you will have a command that looks similar to the following:

Select (CASE "{?Parameter}"

WHEN 'Value1' THEN 'Message'

ELSE 'General Message'

END) AS X FROM Xtreme.dbo.Customer

The double quotes around the parameter indicate that you are selecting a column from your database, and the WHEN/ELSE indicates the messages you will see depending on the value in that column.

This issue occurs even if you attempt to set the parameter in advance using the ParameterFieldController method of passing parameters.

Cause

When the JRC does a setTableLocation and the report contains a command with a parameter, and you attempt to set the parameter value using the ParameterFieldController, the parameter value is not propagated to the command parameter. The issue will also occur if you allow the viewer to prompt for the parameter.

Resolution

Use the IProcedure object. The documentation for this is can be found in the Report Application Server SDK Java section, in the Developer Library.
 
You cast your command to an IProcedure object, at which point you can extract and set the parameter value. See the following code as an example:

if(table instanceof com.crystaldecisions.sdk.occa.report.data.CommandTable)

{
           IProcedure command = (IProcedure)table;

ParameterField commandParam = (ParameterField) command.getParameters().get(0);

           Values values = new Values();

ParameterFieldDiscreteValue pfdv = new ParameterFieldDiscreteValue();

           pfdv.setValue("ANTON");

           values.add(pfdv);

           commandParam.setCurrentValues(values);
}

Keywords

JRC, Java Reporting Component, Eclipse, Database, Command, Error, Invalid, Column, Parameter, null , 1856394 , KBA , BI-DEV-JAV , BI Software Development Kits (SDKs) - Java , Bug Filed

Product

SAP Crystal Reports XI ; SAP Crystal Reports XI R2