Crystal Reports:
User Function Libraries (UFLs) That Remember State
See also: Crystal Reports: User Function Libraries in Crystal Reports
User Function Libraries (UFL) are
supposed to be stateless. That
means a UFL starts with some values, does all the processing required,
and then finishes its work. The next run of
the formula doesn't remember the values from the previous run
However, you can write a UFL that
does remember state, and you can use a series of functions inside formulas
to build disk files, write XML documents, send email to an SMTP server,
etc. We have several of these already written and available from our Web
site.
See the menu at left, or click here:
http://www.crystalkeen.com/crystalreporttools/ufls/
An occasional problem occurs with
UFLs. It appears that the
UFL is processed more than once, but only every now and then. Discussions with CD revealed that this is because the section is
processed, formatted, and then checked to see if it will fit on the bottom
of the page.
If it doesn't
fit, the page footer and header are processed. Then, section is reprocessed for the top of the new page.
To remove this problem do the
following:
1.
Write the report that uses your UFL functions in formulas.
2. Create a section above the
section where you do all the work, Details (a). This section must have a height, and can’t be suppressed or set
to Underlay. Using Underlay,
Suppress, or Suppress Blank Section on this section all cause duplicate
records.
3. Create a set of formulas as
follows:
Reset Counter:
Place in RH and PF sections
WhilePrintingRecords;
global numbervar c:=0
New Line: Place in the Details (a)
section.
This can be formatted with “Suppress”
WhilePrintingRecords;
global numbervar c:= c + 1
4. Set a conditional “New Page
After” on Details (a)
WhilePrintingRecords;
global numbervar c;
c >= 60
|