The LABEL RECORDS clause specifies whether a file contains labels and, if so, their format. This clause appears in the File Description (FD) entry within the FILE SECTION and is essential for proper file identification and management, especially in mainframe environments with tape files and disk datasets.
1LABEL RECORDS ARE {STANDARD | OMITTED | data-name-1 [, data-name-2]...}
The LABEL RECORDS clause can be specified in three ways:
STANDARD indicates that the file has labels conforming to system specifications. This is commonly used for:
12345FD CUSTOMER-MASTER LABEL RECORDS ARE STANDARD RECORD CONTAINS 200 CHARACTERS BLOCK CONTAINS 50 RECORDS DATA RECORDS ARE CUSTOMER-RECORD.
OMITTED specifies that the file does not have labels. This is typically used for:
1234FD REPORT-FILE LABEL RECORDS ARE OMITTED RECORD CONTAINS 132 CHARACTERS DATA RECORD IS REPORT-LINE.
You can specify user-defined label names, though this is rarely used in modern COBOL:
123FD SPECIAL-FILE LABEL RECORDS ARE CUSTOM-LABEL-1, CUSTOM-LABEL-2 RECORD CONTAINS 100 CHARACTERS.
1234567891011121314151617181920212223ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT TRANSACTION-TAPE ASSIGN TO "TRANS.TAPE" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS WS-TRANS-STATUS. DATA DIVISION. FILE SECTION. FD TRANSACTION-TAPE LABEL RECORDS ARE STANDARD BLOCK CONTAINS 100 RECORDS RECORD CONTAINS 80 CHARACTERS DATA RECORDS ARE TRANSACTION-RECORD. 01 TRANSACTION-RECORD. 05 TRANS-ID PIC X(10). 05 TRANS-DATE PIC 9(8). 05 TRANS-AMOUNT PIC S9(10)V99. 05 TRANS-TYPE PIC X(5). 05 TRANS-ACCOUNT PIC X(15). 05 TRANS-DESCRIPTION PIC X(30).
12345678910111213141516ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT REPORT-FILE ASSIGN TO "REPORT.OUTPUT" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS WS-REPORT-STATUS. DATA DIVISION. FILE SECTION. FD REPORT-FILE LABEL RECORDS ARE OMITTED RECORD CONTAINS 132 CHARACTERS DATA RECORD IS REPORT-LINE. 01 REPORT-LINE PIC X(132).
123456789101112131415161718192021222324252627ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CUSTOMER-MASTER ASSIGN TO "CUSTMAST.DAT" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS WS-MASTER-STATUS. DATA DIVISION. FILE SECTION. FD CUSTOMER-MASTER LABEL RECORDS ARE STANDARD BLOCK CONTAINS 50 RECORDS RECORD CONTAINS 200 CHARACTERS DATA RECORDS ARE CUSTOMER-RECORD. 01 CUSTOMER-RECORD. 05 CUST-ID PIC X(10). 05 CUST-NAME PIC X(40). 05 CUST-ADDRESS PIC X(60). 05 CUST-PHONE PIC X(15). 05 CUST-CREDIT-INFO. 10 CUST-CREDIT-LIMIT PIC 9(8)V99. 10 CUST-BALANCE PIC S9(8)V99. 10 CUST-LAST-PAYMENT PIC 9(8). 05 CUST-STATUS PIC X(10). 05 FILLER PIC X(47).
12345678910111213141516171819ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT WORK-FILE ASSIGN TO "WORK.FILE" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS WS-WORK-STATUS. DATA DIVISION. FILE SECTION. FD WORK-FILE LABEL RECORDS ARE OMITTED RECORD CONTAINS 120 CHARACTERS DATA RECORDS ARE WORK-RECORD. 01 WORK-RECORD. 05 WORK-KEY PIC X(15). 05 WORK-DATA PIC X(100). 05 WORK-FLAGS PIC X(5).
| Option | Use Case | Example Files |
|---|---|---|
| STANDARD | Files requiring system-managed file identification and volume management | Tape files, disk datasets, production data files, master files |
| OMITTED | Files that don't require label processing or where labels are managed externally | Printer files, report files, temporary work files, console output |
| User-defined | Custom label processing requirements (rarely used) | Specialized file formats with custom label handling |
If the LABEL RECORDS clause is omitted entirely, the default behavior depends on the COBOL implementation:
Best Practice: Always explicitly specify LABEL RECORDS to avoid ambiguity and ensure code portability across different COBOL implementations.
In modern COBOL implementations, the LABEL RECORDS clause is often treated as syntax-only and may not affect program execution. File labeling is typically managed by:
However, the clause is still required syntax for proper file descriptions and should be included for:
1234FD INPUT-FILE LABEL RECORDS ARE STANDARD RECORD CONTAINS 100 CHARACTERS DATA RECORD IS INPUT-RECORD.
1234FD OUTPUT-FILE LABEL RECORDS ARE STANDARD RECORD CONTAINS 150 CHARACTERS DATA RECORD IS OUTPUT-RECORD.
1234FD REPORT-FILE LABEL RECORDS ARE OMITTED RECORD CONTAINS 132 CHARACTERS DATA RECORD IS REPORT-LINE.
Explicitly specify LABEL RECORDS in every FD entry to avoid ambiguity and ensure code portability.
Use LABEL RECORDS ARE STANDARD for all production data files, tape files, and disk datasets that require proper file identification.
Use LABEL RECORDS ARE OMITTED for printer files, report files, and temporary work files that don't require label processing.
Add comments explaining why you chose STANDARD or OMITTED for each file, especially if the choice is non-obvious.
Imagine files are like boxes with name tags:
When you have a box, you might put a name tag on it so you know what's inside. LABEL RECORDS STANDARD is like having a special name tag that the computer system writes and manages for you - it tells everyone what's in the box and where it came from.
LABEL RECORDS OMITTED is like a box without a name tag - maybe it's a temporary box you're using right now, or maybe the name tag is written somewhere else. The computer doesn't need to manage a name tag for this box.
Just like you choose whether to put a name tag on your box, COBOL programs choose whether files need system-managed labels or not!
Write a complete FD entry for a tape file named BACKUP-TAPE that contains 500-character records, uses standard labels, and blocks 200 records.
12345FD BACKUP-TAPE LABEL RECORDS ARE STANDARD BLOCK CONTAINS 200 RECORDS RECORD CONTAINS 500 CHARACTERS DATA RECORD IS BACKUP-RECORD.
Write a complete FD entry for a report file that prints 80-character lines and doesn't need labels.
1234FD REPORT-FILE LABEL RECORDS ARE OMITTED RECORD CONTAINS 80 CHARACTERS DATA RECORD IS REPORT-LINE.
Create a complete file definition (FILE-CONTROL and FD) for a customer master file with standard labels, 200-character records, and 50-record blocks.
123456789101112131415ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CUSTOMER-MASTER ASSIGN TO "CUSTMAST.DAT" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS WS-MASTER-STATUS. DATA DIVISION. FILE SECTION. FD CUSTOMER-MASTER LABEL RECORDS ARE STANDARD BLOCK CONTAINS 50 RECORDS RECORD CONTAINS 200 CHARACTERS DATA RECORDS ARE CUSTOMER-RECORD.
1. What does LABEL RECORDS STANDARD indicate?
2. Which LABEL RECORDS option is typically used for printer files?
3. Where does the LABEL RECORDS clause appear?
4. What is the default behavior if LABEL RECORDS is omitted?
5. Which file type most commonly uses LABEL RECORDS STANDARD?