cancel
Showing results for 
Search instead for 
Did you mean: 

Array error message

Former Member
0 Kudos

Hi All,

I have a string that I am creating that concatenates values separated by a "^". This is in my main report.

I linked the string to a subreport. When I display the string in the subreport, it shows up. When I try to split it, I get the following error message: "An array's dimension must be an integer between 1 and 1000."

Main Report (Group Footer):

whileprintingrecords;

stringvar arrquoteid;

arrquoteid:=arrquoteidtotext({Quote.quoteid})"^"

SubReport (Details):

WhileReadingRecords;

stringVar array arr;

numberVar i;

arr:=split({?Pm-@arrQuoteID},"^");

i:=i+1;

if i<= Count(arr) and arr<i><>"" then

tonumber(arr<i>)

else

0

What am I doing wrong to receive the above error message?

Thank you in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

In crystal reports an array can store only 1000 values. This is by design. I think this error is because you didn't mention the index value for an array. Try this

WhileReadingRecords;
stringVar array arr; 
numberVar i;
arr:=split({?Pm-@arrQuoteID},"^");
i:=i+1;
if i<= Count(arr) and arr<i><>"" then
tonumber(arr<i>)
else 
0

If you are still getting the error then try this

WhilePrintingRecords;
stringVar array arr; 
numberVar i;
arr:=split({?Pm-@arrQuoteID},"^");
i:=i+1;
if i<= Count(arr) and arr<i><>"" then
tonumber(arr<i>)
else 
0

Regards,

Raghavendra.G

Former Member
0 Kudos

I tried you suggestions. It still gives me the same error. Coming to think of it, I do have over 1000 records.

Former Member
0 Kudos

If you have more than 1000 values then you need to try this

WhilePrintingRecords;
stringVar array arr; 
numberVar i;
arr:=split({?Pm-@arrQuoteID},"^");
i:=i+1;
if i<= 1000 and arr<i><>"" then
tonumber(arr<i>)
else 
0

If the above formula is working fine then you need to create 2 arrays based on the count of array values to accomodate more than 1000 values

Regards,

Raghavendra

Former Member
0 Kudos

Tried you last suggestion and it still didn't like it. When it gives me the error, it highlights this part of the formula: split({?Pm-@arrQuoteID},"^")

Former Member
0 Kudos

Antoine,

Try using single quotes instead of double quotes:

split({?Pm-@arrQuoteID},'^')

Former Member
0 Kudos

Same result.

Former Member
0 Kudos

Try to remove the link in the change subreport links and use a shared variable in the main report formula and pass the value to the sub report.

Regards,

Raghavendra

Former Member
0 Kudos

Same error even with the shared variable.

Former Member
0 Kudos

can you paste the formulas with shared variables?

Regards,

Raghavendra

Former Member
0 Kudos

Sure.

Main:

whileprintingrecords;

shared stringvar arrquoteid;

arrquoteid:=arrquoteidtotext({Quote.quoteid})"^"

Subreport:

WhilePrintingRecords;

stringvar array arr;

shared stringvar arrquoteid;

numberVar i;

arr:=split(arrquoteid,"^");

i:=i+1;

if i<= count(arr) and arr<i><>"" then

tonumber(arr<i>)

else

0

Former Member
0 Kudos

Did you place your sub report in the footer section after processing the formula? if so then try this in sub report

WhilePrintingRecords;
stringvar array arr;
shared stringvar arrquoteid;
numberVar i;
redim preserve arr[1000];
arr:=split(arrquoteid,"^");
i:=i+1;
if i<= 1000 and arr<i><>"" then
   tonumber(arr<i>)
else 
   0

If you are still getting the error then try to place the following formula in sub report header and see whether you are able to see the values.

WhilePrintingRecords;

shared stringvar arrquoteid;

Regards,

Raghavendra

Former Member
0 Kudos

Your error is probably because, as you say, you have more than 1000 records. It doesnt matter if you check for 1000 after the fact, since the split function would have failed.

Here is one way to get around it.

1. In your subreport formula, get the count of the 999th ^ in the string arrquoteid. Then split arrquoteid from 1 to the count of the 999th ^ based on ^.

2. Then you can do this:

i:=i+1;

if i<= count(arr) and arr<>"" then

tonumber(arr)

else

0

Makes sense?

Former Member
0 Kudos

Still doesn't work. Yes I do see the string in the sub report header.

Former Member
0 Kudos

This worked:

WhilePrintingRecords;

stringvar array arr;

shared stringvar arrquoteid;

numberVar i;

arr:=split(arrquoteid,"^",1000);

i:=i+1;

if i<= 1000 and arr<i><>"" then

tonumber(arr<i>)

else

0

However, I cannot exceed 1000. Is there a reason for this limitation in Crystal?

Former Member
0 Kudos

This is by design. See the following SAP Note

[https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313331333933383338%7D.do]

Regards,

Raghavendra

Answers (0)