Despite all the Crystal Reports functionality covered, to this point, it would be understandable if you assumed that the Crystal Reports reporting engine provides all this power with a single pass through the data it retrieves from the database. This would be a faulty assumptionCrystal Reports actually uses a three-pass reporting methodology to generate reports. Understanding the multi-pass nature of the reporting engine can facilitate effective report design and expedite the debugging of potential reporting challenges. Figure 4.25 from the Crystal Reports online Help file provides a good starting point for understanding the different passes through the data that Crystal Reports makes and what is calculated on each pass. Figure 4.25. Understanding the Crystal Reports Multi-Pass report engine flow can help in creating and debugging Crystal Reports.Crystal Reports Processing EnginePre-Pass #1In the Pre-Pass phase of report creation, only constant formulas are processed. A constant formula example might be 1967*10. These formulas are evaluated at the beginning of the print generation process and are never evaluated again. This process is known as "BeforeReadingRecords." Crystal Reports Processing EnginePass #1After the constant formulas have been processed, Crystal Reports begins reading the database records. During the record reading process, known as "WhileReadingRecords," the following occurs:
Crystal Reports Processing EnginePre-Pass #2During Pre-Pass #2, groups are ordered in the report for Top/Bottom N and/or Hierarchical Grouping. The reporting engine looks at group instances from Pass 1, and takes the Top N as appropriate, or orders the groups based on the specified Hierarchical Group settings. Crystal Reports Processing EnginePass #2Crystal Reports moves through the saved data, if required, to complete any remaining operations and initiates printing of the records in this phase known as "WhilePrintingRecords." During this phase, the following takes place:
Caution Subtotals, grand totals, and summaries might appear incorrectly if the report has a group selection formula. This occurs because the grand totals and summaries are calculated during Pass 1, but the group selection formula filters the data again in Pass 2. Running total fields or Formula fields with variables can be used instead of summaries to total data successfully with group selection formulas. Crystal Reports Processing EnginePass #3In the third and final pass, the total page count is determined. This applies to reports that use the total page count, or Page N of M special fields. Understanding the multi-pass reporting paths of the Crystal Reports engine helps in the general development and debugging of your production reports. Additional leveraging of the built-in Formula functions discussed previously (BeforeReadingRecords, WhileReadingRecords, and WhilePrintingRecords) in combination with the EvaluateAfter() function enable you to design more flexible reports and formulas. These functions also enable you to leverage advanced variable usage and successful sharing among subreports. |