exclusivesoftware.com
Home arrow Support arrow How Do I ...? arrow Two Pass Reports
Main Menu
Home
Products
Services
Support
Contact
Two Pass Reports PDF Print E-mail

  The idea behind a two-pass report is that sometimes it is necessary to write two reports to get the desired output. The first pass is commonly used to generate a data file, which can then be used by the second report to obtain the final results. Under most circumstances a two-pass report is not necessary, but there are a few instances where it is.

Identifying the Problem

  Two-pass reports are usually needed when it is not possibly to determine whether a record is needed using values from a constant, definition, or a field located within the same record. An example of this dilemma is present when we are trying to find matching pieces of equipment( ITEM) in two different locations. Every location would have a record for each ITEM, and that same ITEM may be present in multiple locations. How would we print a report that showed common equipment in two different locations?

The First Pass

  Probably the best thing to do is to rearrange the data, to reflect the way we intend to group it. Lets say we are interested in ITEMswpe2.jpg (3003 bytes) located in "A" and "B", so we know we should sort by ITEM. The results will give us a data that looks more like figure 3. We can also tell from figure 1 that we have some locations in the data we are not concerned with. We can easily eliminate the other locations by specifying selection criteria that only allows Locations of type "A" or "B".

"IF LOCATION EQ "A"
"IF LOCATION EQ "B"

  After the selection criteria are applied to the data we get results like figure 3.wpe2.jpg (2720 bytes)Although it looks better than previous results, we still have redundant information about each ITEM that we can simplify. We know we can summarize the information about a particular ITEM using the "NODETAIL" option, but we would not know if the ITEM was in "A", "B", or both. So we most define flags that indicates the ITEM's presence in one of the desired locations.

In our report we could define two flags, called IN.A and IN.B.

wpe3.jpg (2639 bytes)wpe4.jpg (2638 bytes)

  A value will be set for IN.A only if it is A, and IN.B only if it is in B, and because we are summarizing the records we need to total the two defines. In addition to the NODETAIL we also need to add a BREAK on ITEM so it summarizes by each ITEM. Now, we can produce one record for each ITEM, by printing the ITEM, IN.A, and IN.B, and any other information we need.

From figure 4, we can see there is one more step to get rid of the ITEMs that are not in both IN.A and IN.B. This is the part that must be done in the second pass.

The Second Pass:

The only thing tricky about the second pass, is that it runs against the first pass. In order for us to do this we must set up the first pass results as a data source within the dictionaries. Before we add the definitions to the dictionaries, the first pass must be run with the OUTPUT "filename" in either the options step or at the print options step. This will create a data file that can be used by the dictionaries.

Now that everything is in place we can add the data file to the dictionaries, by adding a new source, and then by adding each of the fields to the new source.

We finish up by writing a second report that will read through all the records selecting the ones were both IN.A and IN.B are equal to one.

IF IN.A EQ IN.B

The above statement will accomplish the same thing as two separate if statements because both fields will never be equal to zero. If both fields ever equal zero, then something went wrong with our first pass.

Adding More Information

We now have all the ITEM numbers we need, we just add any pertinent information necessary for the report. If information is required from other sources, then relationships to the desired sources will need to be defined within the dictionaries.

We have just finished a simple report that finds matching ITEMs in two different location. Although a two-pass report is more work than a single-pass, under certain conditions it is the only way to get the desired results.

 
< Prev
© 2010 exclusivesoftware.com
Joomla! is Free Software released under the GNU/GPL License.