Function
The GENERATE statement directs the Report Writer to produce a portion of the report in accordance with the report description specified in the REPORT SECTION of the Data Division.
Format
GENERATE {data-name | report-name}
Syntax rules
data-name must be defined in the REPORT SECTION of the Data Division, as the name of a detail report group (01-level entry).
The report-name must be defined as such (RD entry) in a report description entry of the REPORT SECTION in the Data Division.
As the result of a GENERATE statement referring to a detail report group, part of the report printed (see rule 5).
As the result of a GENERATE statement referring to a report-name, part of a report is printed (see rule 8).
As the result of a GENERATE statement referring to a detail report group, the Report Writer generates part of the report. The composition of this portion is indicated in syntax rules 6 and 7. In addition, various summations are generally executed (see section "SUM clause").
When executing the (chronologically) first GENERATE statement (relative to the execution of the related INITIATE statement), the following report groups (if defined) will be printed, provided this statement specifies a detail report group:
report heading
page heading
all control headings from the highest to the lowest levels of hierarchy, and
the detail report group specified in the GENERATE statement.
If a GENERATE statement specifying a detail report group is not executed as the (chronologically) first statement, the Report Writer will first check whether a control break occurred. If so, the following report groups are written in the order stated:
All control footings from the lowest level up to, and including, the level at which the control break occurred, and all control footings from the control break level down to the lowest level of hierarchy.
The detail report group specified by the GENERATE statement.
Step a) is not applicable unless there was a control break.
As a result of a GENERATE statement referring to a report, the Report Writer takes the same actions, except for the creation of a detail report group, which is not applicable here. No additional actions beyond syntax rules 5, 6 and 7 will be taken.
When a page becomes full in the course of printing a report, the Report Writer automatically generates a page advance, preceded by the page footing (if present) of the previous page and followed by the page heading of the new page.
General rules
At the time of executing a GENERATE statement which specifies a detail report group, the following information must be available to the Report Writer:
All of the SOURCE clause information assigned to the detail report group and all other report groups to be created by the GENERATE statement.
The numeric data of those addends the Report Writer needs to accumulate the necessary sums.
Summary report printing is meaningful only for those reports for which control footings, too, are defined whose descriptions include SUM clauses.
Summary reporting should not be attempted for reports whose descriptions contain more than one detail report group because it does not allow relations to be established to the individual detail report groups.
The CBL-CTR special register (see section "CBL-CTR special register" ) is interrogated by the Report Writer at the time of the (chronologically) first GENERATE statement. By using the MOVE statement to supply one of several defined values to this special register any time between the execution of the INITIATE statement and the (chronologically) first GENERATE statement, the programmer can select one or both of the following Report Writer options:
Supply appropriate control data item values to the control footings, the page footing and the page heading.
Condition execution of the NEXT GROUP clauses in the control footings (see section "CBL-CTR special register").