Skip to content

Terminate Statement

The TERMINATE must be the last report writer statement to be executed for each report.

terminate

Terminate Statement: Coding Rules

  • Each report-name must be the name of a report in the current program, or that of a GLOBAL report defined in a containing program. (The report-name appears immediately after the RD level-indicator and also in the REPORT clause in the corresponding FD.)

  • TERMINATE must not appear in a USE BEFORE REPORTING directive Declarative.

Terminate Statement: Operation

  • A TERMINATE must be executed for every report that has been INITIATEd before the final close-down of the program.

  • The TERMINATE statement clears any pending REPEATED groups or Page Buffer contents. It also outputs any final CONTROL FOOTING, PAGE FOOTING and REPORT FOOTING groups that may be required at the end of the report. It then returns the report to an "uninitiated" state. PAGE-COUNTER and LINE-COUNTER will contain the final values they attained at the end of the report, but total fields will be zero, except under erroneous circumstances.

  • A separate, subsequent CLOSE should be executed for the associated report file. TERMINATE does not CLOSE the file.

  • If a TERMINATE is executed without any GENERATE statements being executed for the report since the INITIATE was executed, no output at all is produced. If you wish to ensure that at least the REPORT HEADING and REPORT FOOTING groups appear, you should in this case GENERATE a blank DETAIL group before the TERMINATE.

  • A report may be TERMINATEd and then INITIATEd again any number of times without closing the report file. The new INITIATE causes PAGE-COUNTER to return to 1 and, if the report has a PAGE LIMIT clause, will re-commence the report on a fresh page.

Terminate Processing Cycle

  • The following is a more thorough description of each stage in the execution of a TERMINATE statement:

  • If your report is DUPLICATED and REPORT-NUMBER is zero, the actions that follow are performed for each duplicate report.

  • If at least one GENERATE has been performed (indicated by the control break indicator being non-negative), the value of each control-id is temporarily altered to the value it had when the last GENERATE was executed, whilst each CONTROL FOOTING group is produced, from lowest to highest.

  • If any REPEATED groups are present, any buffered groups are output and the REPEATED buffer is flushed. Also, if the Page Buffer contains any data, this is output.

  • If a PAGE FOOTING group is present, it is produced.

  • If a REPORT FOOTING group is present, it is produced.

  • If your report is associated with an Independent Report File Handler, the file handler is invoked with an action code of 8. (If your report is DUPLICATED, this will only take place for reports that have been INITIATEd.)

  • The current vertical position location is set to -1 to indicate "report not initiated".

  • If any total fields are still non-zero, indicating that they have not all been output, an error diagnostic 15 is signalled.

  • If normal batch printing is in effect, a check is made of the error diagnostic flag and an appropriate run time error message is logged if necessary.

Compatibility

The coding rules for TERMINATE are identical for OS/VS COBOL and DOS/VS COBOL Report Writer and new Report Writer. The TERMINATE statement may perform more actions because of the additional functions provided by new Report Writer.

Access to a GLOBAL report is not available with OS/VS or DOS/VS COBOL.

Back to top