Symptom
- Error: "An array's dimension must be an integer between 1 and 1000."
- When refreshing a report in Crystal Reports, it open a formula, and displays the error:
"An array's dimension must be an integer between 1 and 1000."
Environment
- SAP Crystal Reports 2011
- SAP Crystal Reports 2013
- SAP Crystal Reports 2016
- SAP Crystal Reports 2020
Reproducing the Issue
- In Crystal Reports, create a report off any data source.
- Create a formula that uses functions like: XIRR, Split,.. For example, create a formula like:
Split({Database Field Values},"-")
- Insert the formula on the report.
- When refreshing the report, it generates the error:
"An array's dimension must be an integer between 1 and 1000."
Cause
- Arrays in Crystal Reports can contain up to a maximum of 1000 elements.
- This error occurs when a formula uses an array, and it is trying to point to access an element of the array higher than 1,000. Since it is not possible, it fails with the error.
Resolution
- When creating a formula that uses an array, ensure you verify in the formula if the array is not going to go over 1,000 elements by adding a condition.
For examples:
Before adding an element to an array, verify there is less than 1,000 value in it, like:
NumberVar x; // Counter uses to incremente the number of values added.
StringVar myValue := {My Database Field Value};
StringVar Array myArray;
If x < 1000 Then
(
x := x + 1;
myArray[x] := myValue;
)
Else
"There is more than 1,000 elements"
A more complex example will be, If we uses the function "Split" to create an array, ensure the character used to divide the string in multiple elements for the array is less than 1,000 by creating a formula like:
Local StringVar myStringValue := <Insert Database Field or value here>;
Local StringVar mySeparator := <Insert separator string here>;Local NumberVar mySeparatorCounter := 0;
Local NumberVar mySeparatorPosition := 1;
Local StringVar myStringValueTemp := myStringValue;// Calculate the number of times the separator appears in the string.
While mySeparatorPosition <> 0 Do
(
mySeparatorPosition := inStr(myStringValueTemp,mySeparator);If mySeparatorPosition > 0 Then
(
MySeparatorCounter := MySeparatorCounter + 1;
If mySeparatorPosition <> Length(myStringValueTemp) Then
myStringValueTemp := myStringValueTemp[mySeparatorPosition+1 to Length(myStringValueTemp)]
Else
myStringValueTemp := "";
);
);// Verify if there is less than 1000 instance of the separator, then generate the array with the function Split,
// otherwise display a message it has more than 1,000 elements.
If mySeparatorCounter < 1000 Then
(
StringVar Array MyResult := Split(MyStringValue,mySeparator);
"Array Populated with data"
)
Else
"There is more than 1,000 elements"
Keywords
CR, array, limit , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , Problem