Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

crystal xi: Incompletely populating a shared array via a subreport

Posted on 2014-12-12
9
Medium Priority
?
453 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
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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 …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

610 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