The PROGRAM-ID paragraph is the only mandatory paragraph within the IDENTIFICATION DIVISION, and it assigns a name to the COBOL program. This name is used to identify the program in various contexts:
12IDENTIFICATION DIVISION. PROGRAM-ID. program-name [IS INITIAL PROGRAM] [PROGRAM|RECURSIVE|COMMON].
IS INITIAL PROGRAM
: Program is initialized each time it's calledPROGRAM
: Default type, standard programRECURSIVE
: Program can call itself directly or indirectlyCOMMON
: Program can be called by any program contained in it or by any program that contains a program that contains it12IDENTIFICATION DIVISION. PROGRAM-ID. PAYROLL-CALC RECURSIVE.
The example above declares a program named PAYROLL-CALC with the RECURSIVE attribute, allowing it to call itself.
The IDENTIFICATION DIVISION can include several optional paragraphs that provide additional information about the program. These paragraphs are primarily documentation and don't affect program execution.
Identifies the person who wrote the program:
1AUTHOR. JOHN SMITH.
Identifies the site or organization where the program will be used:
1INSTALLATION. ACME FINANCIAL SERVICES.
Indicates when the program was written (format varies):
1DATE-WRITTEN. 2023-07-15.
Shows when the program was compiled. Some compilers automatically update this:
1DATE-COMPILED.
Indicates the security classification or access restrictions:
1SECURITY. CONFIDENTIAL.
1234567IDENTIFICATION DIVISION. PROGRAM-ID. GL-REPORT. AUTHOR. JANE WILSON. INSTALLATION. GLOBAL BANKING CORPORATION. DATE-WRITTEN. 2023-05-22. DATE-COMPILED. SECURITY. RESTRICTED.
The example above shows an IDENTIFICATION DIVISION with all optional paragraphs included.
The REMARKS paragraph allows for extended documentation within the program. In older COBOL standards, this was one of the few places where programmers could add detailed comments. Modern COBOL versions allow comments anywhere in the program.
1234REMARKS. This is a comment about the program. It can span multiple lines. Each line in this area is treated as a comment.
In modern COBOL, the REMARKS paragraph is less commonly used, as programmers can add comments anywhere in the program using an asterisk (*) in column 7 or use in-line comments starting with two adjacent asterisks (**).
12345678910111213IDENTIFICATION DIVISION. PROGRAM-ID. INVENTORY-REPORT. * This is a comment using the asterisk in column 7 REMARKS. This program generates inventory reports with the following features: - Monthly stock levels - Reorder suggestions - Valuation reports - Usage trends The program requires the following input files: - STOCK-MASTER - TRANSACTION-HISTORY
The example above shows the REMARKS paragraph used for extended documentation of program features and requirements.
Though many of the IDENTIFICATION DIVISION paragraphs are optional and serve documentation purposes, following best practices can improve program maintenance and readability.
Choose clear, descriptive program names that indicate function:
CUSTOMER-STATEMENT-PRINT
PGMX01
Many organizations include version information:
1AUTHOR. MARK JOHNSON. VERSION 2.3.
Establish team standards for what information to include:
In the REMARKS section, maintain a record of significant changes:
1234REMARKS. 2023-06-01: Added tax calculation for international orders 2023-04-15: Fixed currency conversion bug 2023-02-10: Initial version
The IDENTIFICATION DIVISION has evolved in modern COBOL standards to support contemporary programming practices while maintaining backward compatibility.
In object-oriented COBOL, new division headers support class definitions:
12IDENTIFICATION DIVISION. CLASS-ID. Employee INHERITS FROM Person.
Methods within classes have their own identification:
12IDENTIFICATION DIVISION. METHOD-ID. calculateSalary.
For defining reusable functions:
12IDENTIFICATION DIVISION. FUNCTION-ID. CALCULATE-INTEREST.
For defining static class features:
12345IDENTIFICATION DIVISION. CLASS-ID. DatabaseConnection. FACTORY. IDENTIFICATION DIVISION. METHOD-ID. getInstance.
While these modern enhancements provide powerful capabilities, many COBOL programs still in production use the traditional program structure. Understanding both the classic and modern approaches is important for COBOL programmers.
Write an IDENTIFICATION DIVISION for a COBOL program with the following requirements:
Try to follow the best practices discussed in this lesson.
1. Which paragraph is mandatory in the IDENTIFICATION DIVISION?
2. What is the maximum length of a program name in standard COBOL?
3. Which clause would you add to the PROGRAM-ID if the program needs to be able to call itself?
4. What is an alternative to using the REMARKS paragraph in modern COBOL?
5. What CLASS-ID would you use to define a class named "Account" that inherits from "BaseAccount"?
Yes, the IDENTIFICATION DIVISION remains essential in modern COBOL. While only the PROGRAM-ID paragraph is mandatory, proper documentation in this division helps with program maintenance, especially in enterprise environments where code may be maintained for decades. Modern COBOL also uses this division for object-oriented constructs like CLASS-ID and METHOD-ID.
Most compilers treat the optional paragraphs (AUTHOR, INSTALLATION, etc.) as comments and don't use them functionally. However, some advanced development environments might extract this information for documentation generation or project management. The DATE-COMPILED paragraph is special as some compilers will automatically update it with the current compilation date.
Standard COBOL limits PROGRAM-ID names to letters, numbers, and hyphens. The name must contain at least one letter and cannot begin or end with a hyphen. Some COBOL dialects may allow additional characters (like underscore), but for maximum portability, stick to these rules. Additionally, the name should not be a COBOL reserved word.
The INITIAL attribute specifies that the program's state (WORKING-STORAGE values) is reset to its initial values each time the program is called. The RECURSIVE attribute allows the program to call itself either directly or indirectly through another program. A program can be both INITIAL and RECURSIVE if needed.