Tuesday, November 01, 2011

Crystal Reports Error: "A subscript must be between 1 and the size of the array." [Field Notes]


A long-standing Crystal Report (being run out of SAP Business Objects XI v12) suddenly started generating an error along the lines of:

Error in File [File Name]: Error in formula [Formula Name]: 'left(split({[Field Name]},"/")[2],3)'
A subscript must be between 1 and the size of the array.
Details: errorKind

(The bracketed values were specific to the report itself)


In this case, the formula is looking for a "/" to split the string. On a hunch, I decided to query the database, and sure enough, some of the fields in the database had been modified and no long included a "/", causing the formula to bomb out.

Two solutions here:

  • If the "/" is a business requirement and is supposed to be there, modify the data.
  • Otherwise, modify the formula to include branching logic that takes other steps if a "/" is not detected.


  1. I prefer the second solution myself. The code should always handle potential exceptions, and the data is always subject to change.

  2. I agree absolutely, but in this particular case, I'm dealing with a report file that is referenced by other reports in a very fragile ecosystem. Changing one in any way could damage the other reports (something I look to change in the future, of course -- but first we have to get onto vNext of this enterprise app.)

    Thanks for the comment, Jim/Dad. :)


Keep it classy, folks.