Exercise two: Using text fields and sorting

In this exercise, we’re going to work with sorting and break processing. In our first exercise, we didn’t specify the order in which we wanted to print the records. When no sort field is specified, records are sorted based on the value of the primary key in the primary file. So in our report, the data was sorted by plant ID and size, the primary key in the plitem file. However, you can sort your report output on any field you choose.

Break processing is a special way of representing sorted data. Let’s say, for example, that we’re sorting a sales report by sales rep. If we also “break” on the sales rep field, we can do special processing when the sales rep data changes, such as printing subtotals by rep or printing additional information before or after the sales rep changes.

Now let’s modify the existing report to sort the plant listing based on the zone in which the plant grows. This report will break on the zone and print subtotals showing the number of plants in each zone. We’ll use a pre‑break line to print the zone for each group.

Selecting a field to sort on

1. Select Design > Fields to sort.

The list of field descriptions is displayed.

2. Select Zone. This will sort the report by the zone field data in each record.
3. Press the Exit shortcut.

Now that you’re in the Sort Fields list, you can tailor the sort to your specifications.

4. Select Sort functions > Change break status.

An uppercase B appears to the left of the field name, indicating ReportWriter will break on the sort field and generate a new page after each break. We don’t want a page break after each zone, so let’s change the break status again.

5. Select Sort functions > Change break status again.

Now the b is lowercase, indicating ReportWriter will break on the field without generating a page break. (See figure 1.)

6. Press the Exit shortcut.  

1. Sorting on the Zone field and setting the break status.

Creating a text field

Now we need to consider what we want to see before each zone break. If we displayed our report right now, the fields we’ve selected would be shown, but the user would have no idea how the report was sorted. So let’s print a heading like this before each break (or grouping of sorted data):

Zone 1

To do this, we need to create a text field that prints “Zone,” and then select that field and the actual zone data field to print in a pre‑break line. First, let’s create the text field.

1. Select Design > Fields to create.

Two lists are displayed: Temporary Fields and Available Field Types.

2. Select Text Fields from the list of Available Field Types.

The Text Field Definition window is displayed with prompts for the field name, a field description (which defaults to the field name), and the text associated with the field.

3. Enter “ZONETEXT” in the Field name field.
4. Press enter in the Description field.
5. Enter “Zone” in the Text field, as shown in figure 2. You’ve now created a text field. User‑created fields are stored in their own temporary file for use in your report.

2. Defining a text field.

6. Press the Exit shortcut (or click OK on Windows).

Adding a pre‑break line

We’ll use our newly‑created text field to create a pre‑break line with this text:

Zone #

1. Select Design > Fields to sort.
2. Select Sort functions > Pre‑break line.
3. Press tab to move to the fields from TEMP selection list. (Pressing tab cycles through the available report files.)
4. Select ZONETEXT.
5. Press tab to move back to the list of fields in the plant item file.
6. Select Zone.
7. Press the Exit shortcut. Your screen should look like figure 3.)

3. Creating a pre‑break line.

8. Press the Display report shortcut to generate the report, as shown in figure 4. Page through it to see the new Zone headings.
9. Press the Exit shortcut to exit when you’re finished viewing the report.

4. Displaying the PLANT LISTING report sorted by zone.

Saving your report

Before going on to exercise three, save your work.

1. Select Operations > Save report.
2. Press enter to continue.

Summary

What you learned…

For more information see…

How to select a field to sort on and specify a break status.

Sorting Your Report

How to create a text field.

Using Temporary Fields

How to place the text field and the sort field into a pre‑break line.

Creating a pre‑ or post‑break line

How to save a report.

Saving a report

Go to Exercise three: Using question fields.