SAP Knowledge Base Article - Public

1209550 - How to display all values in a multiple-value or ranged-value parameter

Symptom

How do I display all values in a multiple-value or ranged-value parameter?

Cause

In Crystal Reports, multiple-value and ranged-value parameters do not display all values entered into the parameter when the parameter is placed on a report. This occurs regardless of whether the parameter includes multiple discrete values, range values, or a combination of the two.

Resolution

To display all entries in a multiple-value parameter, create a formula to extract the parameter values and then concatenate them into a string.

The formula examples below display all values in a multiple-value numeric parameter named "Parameter". Use the first two formulas with parameters that allow ranged only or ranged and discrete values. Use the second two formulas with parameters that allow only discrete values.

Samples below are written in Basic syntax and Crystal syntax.

 

NOTE

Format the formula field object to Can Grow so that all parameter values will display. The parameter values are separated by carriage returns.

 

Discrete Values Only - Basic Syntax

whileprintingrecords
dim counter as number
'increments the loop so that all parameter entries can be displayed
dim display as string
'creates a string "running total" so that all entries can be displayed
Do While count({?Parameter}) > counter
counter = counter + 1
display = display + totext({?Parameter}(counter),0,"") + chr(10)
Loop
formula = display

Discrete Values Only - Crystal Syntax

whileprintingrecords;
global numbervar counter;
//increments the loop so that all parameter entries can be displayed
global stringvar display;
//creates a string "running total" so that all entries can be displayed
for counter := 1 to count({?Parameter}) do
(
display := display + totext({?Parameter}[counter],0,"") + chr(10);
);
display;

Discrete String Values Only - Basic Syntax

whileprintingrecords
formula = join({?Parameter}, chr(10))

Discrete String Values Only - Crystal Syntax

whileprintingrecords;
join({?Parameter}, chr(10));

Ranged Only or Ranged and Discrete Values - Basic Syntax

whileprintingrecords
dim increment as number
'increments the loop so that all parameter entries can be displayed
dim output as string
'creates a string "running total" so that all entries can be displayed
Do While count({?Parameter}) > increment
increment = increment + 1
IF maximum({?Parameter}(increment)) <> minimum({?Parameter}(increment)) _
THEN output = output + totext(minimum({?Parameter}(increment)),0,"") + " to " + totext(maximum({?Parameter}(increment)),0,"") + chr(10) _
ELSE output = output + totext(minimum({?Parameter}(increment)),0,"") + chr(10)
Loop
formula = output

Ranged Only or Ranged and Discrete Values - Crystal Syntax

whileprintingrecords;
global numbervar increment;
//increments the loop so that all parameter entries can be displayed
global stringvar output := "";
//creates a string "running total" so that all entries can be displayed
for increment := 1 to count({?Parameter}) do
(
if minimum({?Parameter}[increment]) = maximum({?Parameter}[increment])
then (output := output + totext(Minimum({?Parameter}[increment]),0,"") + chr(10);)
else (output := output + totext(Minimum({?Parameter}[increment]),0,"") + ' to ' + totext(Maximum({?Parameter}[increment]),0,"") + chr(10););
);
output;

TIP

If the code sample is truncated in your browser window, copy and paste the entire block of code into a text editor. Code samples are intentionally formatted this way so they do not wrap. Wrapped code can produce unexpected errors in your application.

 

NOTE

The maximum length of any formula's output for Crystal Reports 9 and later is 64K characters.

The maximum length of any formula's output for Crystal Reports 8.5 and earlier is 255 characters.

See Also

The output of the display formula must be a string. Therefore, it is necessary to convert all non-string data using the ToText() function. When converting parameter values to text use format strings to control the appearance of the final output.

For more information on the ToText() function, refer to the Crystal Reports Online Help by pressing the F1 key.

Multiple-value or ranged-value parameters are treated as real arrays in Crystal Reports. For more information on arrays, refer to the technical brief, Advanced reporting techniques using arrays.

Keywords

PARAMETER DISPLAY VALUES BASIC SYNTAX DISPLAY ALL SCR_DISPLAYPARAM.PDF Crystal Reports Parameter output Discrete and range values , c2002968 , KBA , BI-RA-CR , Crystal Reports designer or BusinessViews Manager , How To

Product

SAP Crystal Reports 10.0 ; SAP Crystal Reports XI ; SAP Crystal Reports XI R2