Skip to content

More about Controls

Each RD entry may have a CONTROL clause, and you may write the names of any number of fields in your program. Your control fields must have a hierarchy and must be listed in order from the highest down to the lowest. When your program issues a GENERATE, report writer tests each control field in order, beginning with the highest. If it detects a change (a control break), this process ends. Report writer will then automatically take additional action before it produces the DETAIL group, depending on which CONTROL FOOTING or CONTROL HEADING report groups (if any) you defined.

COBOL-IT Report Writer keeps an internal copy of each of your control fields so that it can test for a control break by comparing them with the new values on each GENERATE. Before it produces your CONTROL FOOTING report groups, it temporarily stores these previous values back into the control fields. So if your CONTROL FOOTING refers to a control field, as a SOURCE for example, you will get the previous or pre-break value, even though the original control field has changed in value.

You may also want a major heading and a major footing at the very start and end of your report. For example, you may want to produce grand totals for the entire report. If so, you may use the reserved word REPORT or FINAL. This is the highest possible control level. If you use it, it must therefore be first in the list of controls in your CONTROLS clause.

There may be fields other than totals or lines that should be produced only once after a control break. These may be inside a report group, where you cannot make use of a separate CONTROL HEADING. You can define them by writing:

controls

The field or line will then appear only on the first occasion after a control break at the level you indicate. (Alternatively, if you use ABSENT AFTER..., the field or line will not appear the first time and will appear every time thereafter until the next control break.) You may also write PRESENT or ABSENT AFTER NEW PAGE, indicating that you want the field or line to appear (or disappear) only on the first occasion after a page advance. Finally, you may code both the control-field and PAGE operands in one clause.

It is possible for a report to have no DETAIL groups at all. This case is called summary reporting. The only body groups coded are CONTROL FOOTING - and possibly CONTROL HEADING - groups. Therefore, since you have no name of a DETAIL group to give in your GENERATE statement, you write: GENERATE report-name.

The next example illustrates all the points made in this section. There are three levels of control, including REPORT, each with a CONTROL FOOTING.

control footing

Back to top