?
Solved

crystal xi: Incompletely populating a shared array via a subreport

Posted on 2014-12-12
9
Medium Priority
?
450 Views
Last Modified: 2014-12-15
Hello,

I am populating an array in a subreport and using it in the main report. The array is created by reading a local excel spreadsheet with one column consisting of Dates. No matter what I try, if I shrink the subreport (I don't want it visible) the array is incompletely populated. (If I suppress it, it doesn't work at all),

In the subreport,  which is located in the report header, I have an Init formula field  in the reports header and a 'create' formula field in the details section
//INIT
shared datevar array holidaydates;
local numbervar knt := count({Holidays_.DatesOnly});
redim holidaydates[knt];
//just so we don't return an array and cause an error
local numbervar i;
for i := 1 to knt do 
    holidaydates[i] := cdate(#01-01-1970#);

//CREATE in details section
whileprintingrecords;
shared datevar array holidaydates;
holidaydates[recordnumber] := cdate({Holidays_.DatesOnly});

Open in new window


THe knt variable is correct. It's just that if I don't totally display every record in the subreport, (check can grow) The array is not totally populated.

MUST I completely display the subreport for this to work?
0
Comment
Question by:OutOnALimbAlways
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 1920 total points
ID: 40497010
In my experience the answer seems to be yes.

Try this to get around the issue

CHange your formulas as shown

//INIT
shared datevar array holidaydates;
local numbervar knt := count({Holidays_.DatesOnly});
redim holidaydates[knt];
//just so we don't return an array and cause an error
local numbervar i;
for i := 1 to knt do 
    holidaydates[i] := cdate(#01-01-1970#);
''

//CREATE in details section
whileprintingrecords;
shared datevar array holidaydates;
holidaydates[recordnumber] := cdate({Holidays_.DatesOnly});
''

Open in new window


Format the sections of the subreport to SUPRESS BLANK SECTION
Right click the section in the left margin
CLick SECTION EXPERT
Click SUPPRESS BLANK SECTION


Format the subreport to SUPPRESS IF BLANK
Right click the subreport
CLick FORMAT SUBREPORT
CLick the last tab
Click SUPPRESS BLANK SUBREPORT

If the subreport is in its own section you can also suppress the section if blank
Right click the section in the left margin
Click SECTION EXPERT
Click SUPPRESS BLANK SECTION

mlmcc
0
 

Author Comment

by:OutOnALimbAlways
ID: 40497106
Thanks mlmcc, that did the job.  I also formatted the detail section of the subreport to print multiple columns and played around with the layout. I guess as long as you can hide the subreport, it's not really a problem, though it does kind of go against the grain to have a "if it ain't shown, it ain't there" kind of situation.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40497566
If you want the subreport to show something just put a field or text in the report header.  By not having anything show in the details and suppressing it when blank the subreport won't grow very much

mlmcc
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 35

Assisted Solution

by:James0628
James0628 earned 80 total points
ID: 40497812
Interesting.  I didn't realize that subreports did that.  I just tried one with a formula that incremented a count for each record.  I suppressed everything but the detail section, and unchecked "Can Grow".  When the subreport was long enough to display all of the records, I got the correct count in the main report.  When the subreport was too short, I got the last displayed count, plus 1, in the main report.  It seems that the subreport reads and "processes" all of the records that will fit, then it reads the next record, prepares the detail section (including evaluating any formulas in the section), but then sees that there's no room for the detail section, so it just quits.  Good to know.

 James
0
 

Author Comment

by:OutOnALimbAlways
ID: 40497910
I swear 75% of programming is learning the undocumented peculiarities in whatever programming language you are using!
0
 

Author Closing Comment

by:OutOnALimbAlways
ID: 40498307
It looks like this is a 'peculiarity' in crystal.  As James says, it is something to keep in mind. I should have mentioned earlier that if you try to simply use an excel spreadsheet in your main report along with another database, it won't work. Crystal warns you that more than one database driver is not supported, and in my case, attempting to use both sql server and excel in one report really screwed up the results.
0
 
LVL 35

Expert Comment

by:James0628
ID: 40498377
FWIW, more than one kind of db in a report can work.  It's not fully supported, so some specific features don't work, but it can be done.  Of course it's best to avoid it if possible.  And if you're not just reading the data sequentially, Excel files can be really slow, since they're not indexed, etc.  FWIW, I got around that by having stored procedures read the Excel data into indexed temp tables, or table variables, and then joining those tables to the other tables.  Multiple users were also a problem with Excel files, so I only used them with some specific reports that were only run occasionally, by a few specific people.

 James
0
 

Author Comment

by:OutOnALimbAlways
ID: 40500850
James, Ty for the extra tips about excel in crystal.
0
 
LVL 35

Expert Comment

by:James0628
ID: 40500914
No problem.

 James
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question