Quiz — Chapter 16: Report Writer
Multiple Choice
1. Which DATA DIVISION section contains the RD entry?
a) FILE SECTION b) WORKING-STORAGE SECTION c) REPORT SECTION d) LINKAGE SECTION
2. Which clause in the FD entry links a file to a report?
a) REPORT IS b) USES REPORT c) REPORT SECTION d) GENERATE
3. What does the INITIATE statement do?
a) Opens the report file b) Starts the report and initializes accumulators c) Writes the first page heading d) Reads the first input record
4. Which report group type prints at the top of every page?
a) REPORT HEADING b) PAGE HEADING c) CONTROL HEADING d) DETAIL
5. What does the SUM clause do in a CONTROL FOOTING?
a) Counts the number of records b) Computes the average of a field c) Automatically accumulates a field's values since the last break d) Subtracts values from a running total
6. What does GROUP INDICATE do on a detail line field?
a) Highlights the field with asterisks b) Prints the field only on the first line of each control group c) Groups identical values together d) Indicates an error condition
7. What is the purpose of the TERMINATE statement?
a) Closes the report file b) Ends the report, producing final footings c) Deletes the report from the system d) Resets all accumulators to zero
8. Which special register tracks the current page number?
a) LINE-COUNTER b) PAGE-NUMBER c) PAGE-COUNTER d) REPORT-PAGE
9. In the RD entry, what does FIRST DETAIL specify?
a) The first detail record to process b) The first line number where detail lines can be printed c) The first control field in the hierarchy d) The first page of the report
10. What happens when you use GENERATE report-name instead of GENERATE detail-name?
a) An error occurs b) Only detail lines are produced c) A summary report is produced with no detail lines d) The report is generated in reverse order
True or False
11. Report Writer can produce HTML and XML output.
12. The CONTROLS clause fields must be listed in the same order as the input file's sort order.
13. You must explicitly code page overflow detection when using Report Writer.
14. SUM values in higher-level CONTROL FOOTINGs automatically cascade from lower-level SUMs.
15. A single COBOL program can contain multiple RD entries for different reports.
Short Answer
16. Explain the difference between REPORT HEADING and PAGE HEADING. When does each appear?
17. Describe three advantages of Report Writer over manual control break processing.
18. What is the "last group" bug in manual control break programs, and how does Report Writer avoid it?
19. You need to produce a report where some detail lines are printed in red and others in black based on the amount field. Can Report Writer handle this? Explain your reasoning and suggest an approach.
20. Maria Chen says: "Standard control-break reports — Report Writer every time. Regulatory reports with conditional columns — manual." What factors drive this decision?
Answer Key
1. c) REPORT SECTION
2. a) REPORT IS
3. b) Starts the report and initializes accumulators
4. b) PAGE HEADING
5. c) Automatically accumulates a field's values since the last break
6. b) Prints the field only on the first line of each control group
7. b) Ends the report, producing final footings
8. c) PAGE-COUNTER
9. b) The first line number where detail lines can be printed
10. c) A summary report is produced with no detail lines
11. False — Report Writer produces fixed-format text output only.
12. True — mismatched control/sort order produces incorrect subtotals.
13. False — Report Writer handles page overflow automatically based on the PAGE LIMIT, FIRST DETAIL, and LAST DETAIL specifications.
14. True — higher-level SUMs accumulate the values from the next-lower-level SUMs automatically.
15. True — a program can define multiple reports, each with its own RD, linked to different files.
16. REPORT HEADING appears once at the very beginning of the report (first page only). PAGE HEADING appears at the top of every page, including the first. REPORT HEADING is for title pages or one-time introductory content; PAGE HEADING is for column headers and identification that should repeat on every page.
17. (1) Automatic page overflow handling eliminates line-counting code. (2) Automatic control break detection eliminates key-comparison logic. (3) Automatic SUM accumulation eliminates manual ADD statements and accumulator management. Additional advantages include automatic GROUP INDICATE, PAGE-COUNTER maintenance, and a clearer separation of report structure (DATA DIVISION) from processing logic (PROCEDURE DIVISION).
18. The "last group" bug occurs when the AT END condition triggers but the final control group's subtotals have not yet been printed. In manual programs, the programmer must remember to perform the control break logic one more time after the read loop ends. Forgetting this means the last group's subtotals are missing from the report. Report Writer avoids this because TERMINATE automatically produces all remaining control footings and the report footing.
19. Report Writer's standard clauses cannot conditionally change formatting based on data values. However, you can use a combination approach: define the detail line field with SOURCE referencing a WORKING-STORAGE field, and use USE BEFORE REPORTING to set that field (including any escape sequences for color) based on the amount. Alternatively, for true color control in a mainframe printing environment, you would need to embed printer control sequences, which is best done in a manual report program. For most practical purposes, this requirement is better served by manual report generation.
20. Standard control-break reports have a regular, predictable structure: repeating detail lines, subtotals at key changes, grand totals at the end. This maps perfectly to Report Writer's declarative model. Regulatory reports often have irregular structures: columns that appear or disappear based on data, conditional sections, embedded computations, specific formatting requirements dictated by regulators. These irregular patterns require procedural control that Report Writer's declarative model cannot easily express. The decision is driven by how well the report's structure matches Report Writer's fixed model of headings, details, and footings.