MainframeMaster

COBOL Tutorial

COBOL FOOTING Clause

The FOOTING clause represents a sophisticated page layout control mechanism within COBOL's Report Writer facility, serving as the primary specification for defining the starting line position of page footer content and bottom margin management. This clause embodies the principles of comprehensive page structure control by providing precise footer positioning capabilities, enabling professional report formatting standards, and supporting consistent bottom-of-page content placement across multi-page documents while maintaining optimal readability and ensuring proper page utilization in enterprise reporting systems and business documentation environments.

Syntax and Usage

FOOTING Syntax
cobol
1
2
3
4
5
6
7
8
9
10
RD report-name PAGE LIMIT IS integer LINES HEADING integer FIRST DETAIL integer LAST DETAIL integer FOOTING integer. 01 page-footer TYPE IS PAGE FOOTING. 05 LINE NUMBER IS FOOTING-LINE. 10 COLUMN 1 PIC X(50) VALUE 'Footer content'.
Report Writer
Page Control
Footer Management

Comprehensive FOOTING Implementation

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
IDENTIFICATION DIVISION. PROGRAM-ID. FOOTING-COMPREHENSIVE-DEMO. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT SALES-INPUT-FILE ASSIGN TO 'SALES.DAT' ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS INPUT-FILE-STATUS. SELECT SALES-REPORT-FILE ASSIGN TO 'SALESRPT.RPT' ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS REPORT-FILE-STATUS. DATA DIVISION. FILE SECTION. FD SALES-INPUT-FILE BLOCK CONTAINS 0 RECORDS RECORD CONTAINS 120 CHARACTERS. 01 SALES-INPUT-RECORD. 05 SALE-ID PIC 9(8). 05 SALE-DATE PIC 9(8). 05 CUSTOMER-ID PIC 9(6). 05 CUSTOMER-NAME PIC X(30). 05 PRODUCT-CODE PIC X(10). 05 PRODUCT-NAME PIC X(25). 05 QUANTITY PIC 9(5). 05 UNIT-PRICE PIC 9(5)V99. 05 SALE-AMOUNT PIC 9(7)V99. 05 SALES-REP PIC X(20). 05 FILLER PIC X(5). FD SALES-REPORT-FILE BLOCK CONTAINS 0 RECORDS RECORD CONTAINS 132 CHARACTERS. 01 SALES-REPORT-RECORD PIC X(132). REPORT SECTION. RD SALES-REPORT CONTROLS ARE FINAL SALES-REP PAGE LIMIT IS 66 LINES HEADING 1 FIRST DETAIL 8 LAST DETAIL 55 FOOTING 60. *> Page Footer starting at FOOTING line 60 01 PAGE-FOOTER TYPE IS PAGE FOOTING. 05 LINE NUMBER IS 60. 10 COLUMN 1 PIC X(25) VALUE 'CONFIDENTIAL DOCUMENT'. 10 COLUMN 40 PIC X(20) VALUE 'SALES DEPARTMENT'. 10 COLUMN 70 PIC X(10) VALUE 'PAGE TOTAL:'. 10 COLUMN 85 PIC ZZ,ZZ9.99 SUM SALE-AMOUNT RESET ON PAGE. 05 LINE NUMBER IS 61. 10 COLUMN 1 PIC X(90) VALUE ALL '-'. 05 LINE NUMBER IS 62. 10 COLUMN 1 PIC X(15) VALUE 'REPORT TIME:'. 10 COLUMN 17 PIC X(8) SOURCE IS WS-REPORT-TIME. 10 COLUMN 40 PIC X(20) VALUE 'CONTINUED ON NEXT PAGE'. 10 COLUMN 70 PIC X(15) VALUE 'LINES ON PAGE:'. 10 COLUMN 90 PIC ZZ9 SOURCE IS LINE-COUNTER. WORKING-STORAGE SECTION. 01 REPORT-VARIABLES. 05 WS-REPORT-DATE PIC X(10). 05 WS-REPORT-TIME PIC X(8). PROCEDURE DIVISION. MAIN-PROCESSING. OPEN INPUT SALES-INPUT-FILE OPEN OUTPUT SALES-REPORT-FILE INITIATE SALES-REPORT PERFORM UNTIL INPUT-EOF READ SALES-INPUT-FILE AT END CONTINUE NOT AT END GENERATE SALES-DETAIL END-READ END-PERFORM TERMINATE SALES-REPORT CLOSE SALES-INPUT-FILE CLOSE SALES-REPORT-FILE STOP RUN.

Key Features and Benefits

Footer Positioning
  • • Defines footer starting line
  • • Ensures consistent bottom margins
  • • Controls page footer placement
  • • Maintains professional appearance
Page Management
  • • Coordinates with LAST DETAIL
  • • Manages footer content area
  • • Supports page totals and summaries
  • • Handles continuation indicators

Interactive Tutorial

Hands-On Exercise: Footer Design
Practice using FOOTING for effective page footer management

Exercise 1: Basic Footer Layout

cobol
1
2
3
4
5
6
7
8
9
10
11
12
RD INVOICE-REPORT PAGE LIMIT IS 66 LINES HEADING 1 FIRST DETAIL 8 LAST DETAIL 58 FOOTING 62. 01 INVOICE-FOOTER TYPE IS PAGE FOOTING. 05 LINE NUMBER IS 62. 10 COLUMN 1 PIC X(20) VALUE 'Invoice continued...'. 10 COLUMN 50 PIC X(5) VALUE 'Page:'. 10 COLUMN 56 PIC ZZ9 SOURCE IS PAGE-COUNTER.

Exercise 2: Multi-Line Footer

cobol
1
2
3
4
5
6
7
8
9
10
01 DETAILED-FOOTER TYPE IS PAGE FOOTING. 05 LINE NUMBER IS 60. 10 COLUMN 1 PIC X(30) VALUE 'Confidential - Internal Use'. 10 COLUMN 60 PIC X(15) VALUE 'Page Total: $'. 10 COLUMN 75 PIC ZZ,ZZ9.99 SUM AMOUNT RESET ON PAGE. 05 LINE NUMBER IS 61. 10 COLUMN 1 PIC X(80) VALUE ALL '-'. 05 LINE NUMBER IS 62. 10 COLUMN 1 PIC X(20) VALUE 'Generated: '. 10 COLUMN 21 PIC X(19) SOURCE IS CURRENT-DATE-TIME.

Best Practices

Knowledge Check

Test Your Understanding

Question 1: Footer Positioning

With PAGE LIMIT 66, LAST DETAIL 58, what's the optimal FOOTING setting?

Answer: FOOTING 62 provides 3 lines buffer after LAST DETAIL and 4 lines for footer content, ensuring proper spacing and adequate footer area.

Question 2: Content Planning

What essential information should be included in page footers?

Answer: Page numbers, report date/time, confidentiality notices, page totals, and continuation indicators are essential footer elements for professional reports.

Question 3: Error Prevention

How do you prevent footer content from overlapping with detail lines?

Answer: Ensure FOOTING is set higher than LAST DETAIL with adequate buffer space (2-3 lines minimum). Test with maximum data volumes to verify spacing.

Common Patterns

Standard Business Footer
cobol
1
2
3
4
5
6
7
8
9
10
11
01 BUSINESS-FOOTER TYPE IS PAGE FOOTING. 05 LINE NUMBER IS 62. 10 COLUMN 1 PIC X(30) VALUE 'Confidential - Internal Use Only'. 10 COLUMN 50 PIC X(5) VALUE 'Page:'. 10 COLUMN 56 PIC ZZ9 SOURCE IS PAGE-COUNTER. 05 LINE NUMBER IS 63. 10 COLUMN 1 PIC X(80) VALUE ALL '-'. 05 LINE NUMBER IS 64. 10 COLUMN 1 PIC X(20) VALUE 'Generated: '. 10 COLUMN 21 PIC X(19) SOURCE IS CURRENT-DATE-TIME.
Financial Report Footer
cobol
1
2
3
4
5
6
7
8
9
01 FINANCIAL-FOOTER TYPE IS PAGE FOOTING. 05 LINE NUMBER IS 60. 10 COLUMN 1 PIC X(25) VALUE 'Financial Report - '. 10 COLUMN 26 PIC X(10) SOURCE IS REPORT-DATE. 10 COLUMN 70 PIC X(15) VALUE 'Page Total: $'. 10 COLUMN 85 PIC ZZ,ZZZ,ZZ9.99 SUM AMOUNT RESET ON PAGE. 05 LINE NUMBER IS 61. 10 COLUMN 1 PIC X(90) VALUE ALL '='.

Frequently Asked Questions