Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shared Array in Subreport issues

Status
Not open for further replies.

mjohns10

MIS
Feb 27, 2007
12
US
Crystal v9
Oracle 8i

I have an array in a subreport that I need to share with my container report. I eventually want to loop through it and compare to see if the values in my container report match, ultimately finding a figure of the difference in value of the total amount in the array and the records that do not match. (i.e. there are 36 recs in array, 29 recs in my container match).

I've successfuly created an array and it populates correctly for the 8 times it is accessed when I declare it as a Global array and redim its size using a summary of the total for the group.

However, once I change the array declaration to Shared so that I can pass it from the Subreport to my Container, the formulas fail giving me an error saying "A subscript must be between 1 and the size of the array"...acting almost as if the redim doesn't exist. And when I try to redim with other ways of getting that same value (i.e. running total) without hard coding it or if I try to create a new Shared variable and give it the value of the Global array, I get an error complaining "The result of a formula cannot be an array". If I don't redim, I go beyond the 1000 limit, and my arrays will only range from 30's to 50's.

Obviously, without being able to delcare it as a Shared array, I can't pass it to the container.

So, my questions:

1- If I know, say, a rounded ceiling of 55 records for array, code "redim[55]", is there a function to cut off the blank empty spaces that would exist in an array that really only had 36 useful records? I assume there should be and that I just don't know it. Hopefully someone can help there.

2 - Once I can get my Subreport array delcared successfully as Shared, how do I relate to it on my container? I get the "The result of a formula cannot be an array" error when I just delcare it like any other non-Array variable:

WhilePrintingRecords;

shared stringVar array charts;



I guess that's it for now. :) I appreciate any help!

I'll gladly provide more info if it would help you help me, too!

 
Anyone have any ideas or somewhere to look to put me in the right direction?
 
Bumping up because I'm still having some trouble with this.


Has no one ever redim'd with a variable rather than hardcoding?


Thanks.
 
I've used a number of Shared array's for similar purposes and the approach that I've found to be successful is this.

In the report header of the main report put a subreport who's sole purpose is to populate your array. In the report header of the subreport put a formula to DIM your array (see example)
Code:
   \\ Dim the array
shared stringvar array valid_app;
   \\ Count the records to go in the array
shared numbervar totalapps := count({DBTABLE.APP_NAME});
   \\ Redim array based on count
redim valid_app [shared numbervar totalapps];

In the Detail of the subreport, put a running total to COUNT the field in question (in this case {DBTABLE.APP_NAME}. Then create a formula to populate the array using a formula similar to the example below:
Code:
shared stringvar array valid_app;
valid_app [{#RTotal0}] :={ALL_LISTS.AL_DESCRIPTION}

Important: You cannot hide or supress the RH in the main report that contains this subreport. To make it transparent, hide or supress each of the sections of the Populate_Array subreport.

Your array should now be fully populated and available from another subreport to perform the comparison's you want to do.

I'm sure there are simplier ways to perform the task of populating the array, but this is at least one way that has worked for me.

Good luck
 
That's good stuff. I'm working on some of it now. Thanks!
 
I just noticed a typo in the code I wrote...
Code:
shared stringvar array valid_app;
valid_app [{#RTotal0}] :=[COLOR=red]{ALL_LISTS.AL_DESCRIPTION}[/color]

should have read...

Code:
shared stringvar array valid_app;
valid_app [{#RTotal0}] :=[COLOR=red]{DBTABLE.APP_NAME}[/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top