SAP Knowledge Base Article - Public

1230352 - How to create one parameter for multiple string values

Symptom

There is a business need to add multiple comments to the report at runtime using parameters.

The solution is to use multiple string parameters, but it does not look elegant when there are multiple parameter prompts and some of them better be optional.

Reproducing the Issue

  • Crystal Reports XI
  • Crystal Reports 10

Cause

Optional parameter is not available functionality prior to Crystal Reports 2008

Resolution

It is possible to use one string parameter for multiple string values and values could be separated by Crystal Reports formulas.

Example:

We need 3 comments to be added to different sections of the report.

Here is the workflow:

  1. Create one String parameter (?Comments) with default value as three delimiters "///" or as a template "Comment1/Comment2/Comment3/"
  2. Parameter prompt should specify that Comments should be separated by forward slashes "/" .
  3. Three separate report formulas are required to use values in the report:

@Comment1 

Stringvar Array ABC := Split ((?Comments,"/");

ABC[1]

@Comment2

Stringvar Array ABC := Split ((?Comments,"/");

ABC[2]

@Comment3 

Stringvar Array ABC := Split ((?Comments,"/");

ABC[3]

     4. Place all formulas in relevant report sections.

Now, if the parameter entered as "A/B/C/", then "A" will be result of formula 1, "B" for 2 and "C" for 3.

Solution works even if none of the values or only some of them entered - it simulates optional parameter functionality.

Keywords

multiple entries, optional prompt , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To

Product

SAP Crystal Reports 10.0