Skip to content

Next Group Clause

This clause is used to create additional vertical space after a group, without causing page overflow if there is no room on the page for the extra blank lines.

next group

Next Group Clause: Coding Rules

  • This clause must be written only at the 01-level.

  • You can use the clause in any body group (DETAIL or CH/CF) and also in a REPORT HEADING (provided that a PAGE HEADING is present) as well as in a PAGE FOOTING (provided that a REPORT FOOTING is present).

  • If your report has no PAGE LIMIT clause, you can use only the + integer-1 form.

  • The optional words BODY and DE OR CH document the effect of the NEXT GROUP clause in the context of the type of group in which it is coded, but they do not have any actual effect on the clause. You can write NEXT BODY GROUP only in a DETAIL or CONTROL HEADING group, and NEXT DE OR CH GROUP only in a CONTROL FOOTING group.

  • DE OR CH may also be written: DETAIL OR CONTROL HEADING, CH OR DE, or CONTROL HEADING OR DETAIL.

Effect of Next Group on Body Groups

Subject to certain constraints, the NEXT GROUP clause causes report writer to increase the value of LINE-COUNTER after all the lines in the body group have been produced, so that the next body group appears on a new page or after an additional vertical gap.

If you write NEXT GROUP + integer-1, report writer will add integer-1 to LINE-COUNTER, but using the LAST CONTROL FOOTING value as a maximum limit. This creates an extra "gap" of that many lines between this group and the next, provided that there is room for both to appear on the same page. The following diagram shows how to use the clause to create more space after a CONTROL FOOTING:

next group effect on body groups

Notice that there is no "gap" after the TOTAL GEORGIA group, because it already extends to the LAST CONTROL FOOTING position. You might suppose that you could also get extra blank lines by writing a blank LINE entry (containing no COLUMN entries or just a VALUE of SPACES) at the end of the group. But this is not a satisfactory replacement for the NEXT GROUP clause, because the blank LINE is treated as a part of the group and will affect the page-fit test. For example, if you had written 03 LINE + 2. or

   03 LINE + 2. 05 COL 1 VALUE " ".

at the end of the CF group instead of the NEXT GROUP clause in the above example, the TOTAL GEORGIA group would have appeared at the top of the next page, because its total depth would now be 5 lines instead of 3. Likewise, a LINE + 2 at the front of the DETAIL group would produce unwanted blank lines ahead of every DETAIL group.

The NEXT GROUP integer-2 (absolute) form may force the next body group to be produced relative to the given line number. Report writer first examines the LINE-COUNTER. If this is less than integer-2 (in other words, if that position has not yet been reached), LINE-COUNTER is set equal to integer-2. Otherwise, report writer sets LINE-COUNTER equal to LAST CONTROL FOOTING to ensure that no more body groups will appear on this page and saves the value of integer-2 in the Saved Next Group Integer location. Before the next body group, if any, is produced, report writer sets LINE-COUNTER equal to the saved integer. It is inadvisable to use this form of the clause unless your next body group will always be a relative group.

If you write NEXT GROUP NEXT PAGE, report writer will set LINE-COUNTER to the LAST CONTROL FOOTING value. This forces report writer to leave the rest of the page blank and begin the next body group, if any, on the next page. (LAST CONTROL FOOTING is the lowest position on which any body group can appear as described under PAGE LIMIT clause).

To begin on a fresh page after a control break, you may place NEXT GROUP NEXT PAGE in the CONTROL FOOTING for that control level, as the following example shows:

next group next page

If you write a NEXT GROUP clause in a CONTROL FOOTING group, report writer checks the level of the control break being processed before putting the clause into effect. If the level of the break is higher than the level of this group, the NEXT GROUP clause is ignored. This means that a CONTROL FOOTING's NEXT GROUP clause can never affect the position of the next CONTROL FOOTING. As the following example shows, the CONTROL FOOTING FOR REPORT (the grand total) will not be forced onto a new page. To document this fact, the optional words DE OR CH are provided in the syntax.

next group control footing

If you should want the CONTROL FOOTING FOR REPORT to appear on a new page in this case, you should instead code ON NEXT PAGE in its first LINE clause.

You can code a dummy report group containing only a NEXT GROUP clause, as in the example below. When the group is processed, no output takes place, but LINE-COUNTER will be set equal to LAST CONTROL FOOTING solely because of the NEXT GROUP NEXT PAGE clause. This may be useful when you want to begin a new page on change of, say, BRANCH, but there is no subtotal that would normally justify coding a CONTROL FOOTING group. Just write: 01 CF FOR BRANCH NEXT GROUP NEXT PAGE.

To obtain a gap of three lines at any time, as an alternative to altering LINE-COUNTER directly, code: 01 THREE-LINE-GAP DE NEXT GROUP + 3. and in your Procedure Division, write: GENERATE THREE-LINE-GAP.

Effect of Next Group on Non-Body Groups

You can write a NEXT GROUP clause in a REPORT HEADING group, in which case the group affected will be your first PAGE HEADING group, which immediately follows the REPORT HEADING. NEXT GROUP NEXT PAGE indicates that the REPORT HEADING is to be by itself on a separate page, rather than on the first page above the PAGE HEADING, but this will be assumed anyway if the REPORT HEADING will not fit above the first PAGE HEADING.

You can also write NEXT GROUP in a PAGE FOOTING group, in which case it affects the REPORT FOOTING. This form is never necessary, as the first LINE clause used in the REPORT FOOTING is a better way to handle this case.

Compatibility

  • Only new Report Writer provides the following features:
  • The optional words BODY and DE OR CH.
  • Optional word ON before NEXT PAGE.
Back to top