Skip to content

Present After Clause

This clause is similar to the PRESENT WHEN clause, except that it tests a condition arising internally within report writer's automatic control-break and page-advance processing, rather than evaluating a general COBOL condition.

present after

Present/Absent After Clause: Coding Rules

  • If you specify the PAGE keyword, the RD for your report must have a PAGE LIMIT clause. If you specify a control-id, then it must be one of the controls listed in your CONTROL clause in the RD, except that REPORT or FINAL is always assumed to be present in the CONTROL clause.

  • You may code this clause at the group or elementary level and may nest clauses.

  • You may use format a in any body group (DETAIL or CH/CF), but, if you use the control-id option in a CONTROL HEADING or CONTROL FOOTING group, the control level you refer to must be higher than the control level of the report group in which the PRESENT AFTER clause is coded.

  • You may also use format a in a PAGE HEADING or PAGE FOOTING group, but only with the control-id option.

  • Format b (with the JUST phrase) can be used only in a body group.

  • Format c, the GROUP INDICATE clause, is provided for compatibility with current standards. Except for one minor but useful difference in its action with OCCURS (see below), it is equivalent to the clause: PRESENT AFTER NEW PAGE OR lowest-control-id where PAGE is present if the report has a PAGE LIMIT clause, and the control-id is present if the report has a CONTROLS clause.

    For example, if the RD entry has the format:

       RD ... 
          PAGE LIMIT 60 LINES 
          CONTROLS BRANCH-NO ZONE-ID.
    
    the GROUP INDICATE clause is equivalent to: PRESENT AFTER NEW PAGE OR ZONE-ID.

  • It is not advisable to refer to an item subject to PRESENT/ABSENT AFTER or GROUP INDICATE in a SUM clause. This is because, according to the ANS standard that applies if the option is in effect, summing takes place before the page-fit, so it not always easy to predict whether the item to be summed will actually be present.

Present/Absent After Clause: Operation

  • The PRESENT AFTER clause operates in a way similar to a PRESENT WHEN clause except that our condition is set from within the report itself. PRESENT AFTER NEW control-id behaves like a clause of the form:

       PRESENT WHEN this group has never yet been output 
               OR a control break has occurred at that level or above 
                  since the last time it was output
    

    while PRESENT AFTER NEW PAGE behaves like a clause of the form:

       PRESENT WHEN this group has never yet been output 
               OR a page advance has taken place 
                  since the last time it was output
    

    To understand this clause fully you should thereafter refer to the Present When clause.

  • If you code PRESENT AFTER NEW control-id, report writer will output the field (elementary or group field), provided that this is the first occasion this report group has been output since the start of the report or since the last control break at the level of control-id or above. For example, if you write PRESENT AFTER NEW BRANCH-NO, your report field will be produced at the beginning of the report and at the first GENERATE after each change of BRANCH-NO (or any higher control). Otherwise, the field is ignored, together with any subordinate entries, in exactly the same manner as with the PRESENT WHEN clause.

    In the following example, the field YEAR-NO is to be output the first time only and then whenever it has changed, while SEASON-NO is to be output the first time and then whenever it or YEAR-NO has changed.

    field year no

  • As is usual with controls, a higher control break implies a control break at all the lower levels. Thus if you code PRESENT AFTER MONTH when YEAR and MONTH are the controls, the field will be PRESENT also after a change of YEAR, for JAN 1992 is certainly different from JAN 1991!

  • If you code PRESENT AFTER NEW PAGE, report writer will produce the entry if this is the first occasion this group has been produced since the start of the report or since the last page advance. Otherwise, again, the field is not output.

    As the following example shows, it may cause the entry to be produced at any position within the page provided the group containing it has not yet appeared on the page. If you want the entry to appear only if this group is also the first body group of the page, you should instead use the form: PRESENT JUST AFTER NEW PAGE. In the example that follows, this would prevent the subheading UNFILLED ORDERS from being printed in the body of the page.

    In the following example, one group has a subheading for unfilled order details and we want this subheading to appear only the first time that the group is printed on the page:

    present after new page

  • If you write PAGE OR control-id (this order can be reversed), the field will be produced if either or both conditions arise. For instance, you might want the YEAR-NO and SEASON fields in the examples above (see above) to be printed again at the start of a new page even though there may have been no change. In this case, you must write:

       05 ... PRESENT AFTER NEW YEAR-NO OR PAGE 
       05 ... PRESENT AFTER NEW SEASON-NO OR PAGE
    
  • There may be a field, line, etc. that you would like produced the first time only. To accomplish this, use PRESENT AFTER NEW REPORT. (REPORT or FINAL is the highest control level and is always assumed even if not coded in the CONTROL clause.) In the next example, it is in the PAGE HEADING:

    upaid subscriptions

    To anchor the vertical starting line of this relative group, you may include a HEADING sub-clause in your RD.

  • If you write ABSENT instead of PRESENT, the clause will have exactly the opposite effect. In other words, the field will be produced whenever it would have been ignored and vice versa. In the next example, we use it to produce a "(CONTINUED)" message in our PAGE HEADING. It will appear on every page except the first page after each new control value. (This message is also useful in CONTROL HEADING groups.)

    absent

  • If there is an OCCURS clause, or a multiple LINES or COLUMNS clause, in the same entry, the PRESENT AFTER applies to the entire set of repetitions, so the occurrences are either all present or all absent. (Compare GROUP INDICATE immediately below.)

  • GROUP INDICATE behaves differently from the equivalent PRESENT AFTER clause if it is subject to OCCURS. As soon as the first occurrence of the GROUP INDICATE item has been output, the GROUP INDICATE is switched off. Hence the GROUP INDICATE clause only enables one entry to be output (the leftmost of topmost, depending on the axis), whereas PRESENT AFTER affects each occurrence equally and is switched off only when the whole table has been output. This fact can be put to practical use if you want some text to appear with the first entry only:

    group indicate

    (Note that if you want "ADDRESS:" to be printed again each time ADDRESS-GROUP is GENERATEd you need to ensure that a control break occurs on each GENERATE of ADDRESS-GROUP.) Using GROUP INDICATE in this example is better than coding PRESENT WHEN R-LINE = 1, since the latter will not work here if the first occurrence of ADDR-LINE might contain spaces.

  • If you use the PRESENT AFTER clause at the 01-level of a DETAIL group: 01 DETAIL-GROUP TYPE DE PRESENT AFTER NEW BRANCH-NO. and you require this group to appear as soon as there is a change to the control BRANCH-NO, your program should GENERATE this group before every other GENERATE for the report. In spite of any appearance to the contrary, you may rest assured that the PRESENT AFTER clause will not make a group appear if your program does not GENERATE it.

Compatibility

Only new Report Writer provides the PRESENT/ABSENT AFTER clause.

New Report Writer allows GROUP INDICATE to appear at any level - not only at elementary level.

Back to top