5: Creating the Demonstration System Reports

5.5 Sorting Records in Reports

Until now we have not changed the order of the records being printed. Normally the records are printed in the same order in which they are stored in the RMSfile. Very often this is un satisfactory as most reports require some kind of ordering of the data. By utilizing the Sorted By fields of the Report Description screen, the records in the RMSfile can be sorted by up to three fields.

Sorting arranges the records in ascending order by comparing sort fields. Each sorted record has sort fields greater than or equal to the sort fields of the previous record and less than or equal to the sort fields of the next record. Sort fields indicate which fields of the record is used to determine the record order. Thus, you can sort subscribers by their name, zip code, and/or state. Our next example will illustrate this sorting capability.

The example in this section further modifies the reportfile that we modified in the preceding section. First, select choice D2 - Modify Report Program from the Report Generator Menu. The Modify Logical Report parameter form is displayed on your screen. Enter mag into the Enter Logical Report Name field and press the STORE key <F5>.

Once the Report Description screen is displayed, press the UPDATE key <F4>. As is indicated in the lower left-hand corner of the screen, you are now in UPDATE mode. This allows you to make the changes to the screen’s contents.

Typing the field name magazine in the left-most Sorted By field sorts the records in the RMSfile mag by the magazine field before printing the report. After pressing the STORE key <F5> to record this change, press the SWITCH key <F7>.

From now on, when you run this report, the records are printed in ascending order, based on the value of the magazine field. When you ‘cycle through’ the various Report Section screens, Level 1 Heading and Level 1 Footing sections now appear, since a single sort field has now been defined. (Note: This example is continued in the following section of this chapter.)