MainframeMaster

COBOL Tutorial

IDENTIFICATION DIVISION

Progress0 of 0 lessons

PROGRAM-ID Paragraph

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:

  • Used in CALL statements from other programs
  • Displayed in system messages and logs
  • Used by job control languages (JCL) to reference the program
  • Specified in compilation and linking operations

Syntax of PROGRAM-ID

cobol
1
2
IDENTIFICATION DIVISION. PROGRAM-ID. program-name [IS INITIAL PROGRAM] [PROGRAM|RECURSIVE|COMMON].

Program Name Rules

  • Must be 1-30 characters in length (varies by compiler)
  • May consist of letters, digits, and hyphens
  • Must contain at least one letter
  • Cannot begin or end with a hyphen
  • Cannot be a COBOL reserved word

Optional Clauses

  • IS INITIAL PROGRAM: Program is initialized each time it's called
  • PROGRAM: Default type, standard program
  • RECURSIVE: Program can call itself directly or indirectly
  • COMMON: Program can be called by any program contained in it or by any program that contains a program that contains it
cobol
1
2
IDENTIFICATION DIVISION. PROGRAM-ID. PAYROLL-CALC RECURSIVE.

The example above declares a program named PAYROLL-CALC with the RECURSIVE attribute, allowing it to call itself.

Optional Paragraphs

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.

AUTHOR Paragraph

Identifies the person who wrote the program:

cobol
1
AUTHOR. JOHN SMITH.

INSTALLATION Paragraph

Identifies the site or organization where the program will be used:

cobol
1
INSTALLATION. ACME FINANCIAL SERVICES.

DATE-WRITTEN Paragraph

Indicates when the program was written (format varies):

cobol
1
DATE-WRITTEN. 2023-07-15.

DATE-COMPILED Paragraph

Shows when the program was compiled. Some compilers automatically update this:

cobol
1
DATE-COMPILED.

SECURITY Paragraph

Indicates the security classification or access restrictions:

cobol
1
SECURITY. CONFIDENTIAL.
cobol
1
2
3
4
5
6
7
IDENTIFICATION 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.

REMARKS Paragraph

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.

REMARKS Syntax

cobol
1
2
3
4
REMARKS. 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 (**).

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
IDENTIFICATION 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.

Common Uses and Best Practices

Though many of the IDENTIFICATION DIVISION paragraphs are optional and serve documentation purposes, following best practices can improve program maintenance and readability.

Meaningful Program Names

Choose clear, descriptive program names that indicate function:

  • Good: CUSTOMER-STATEMENT-PRINT
  • Poor: PGMX01

Version Control Integration

Many organizations include version information:

cobol
1
AUTHOR. MARK JOHNSON. VERSION 2.3.

Standardized Documentation

Establish team standards for what information to include:

  • Required contact information
  • Standard format for dates
  • Consistent security classifications

Change History

In the REMARKS section, maintain a record of significant changes:

cobol
1
2
3
4
REMARKS. 2023-06-01: Added tax calculation for international orders 2023-04-15: Fixed currency conversion bug 2023-02-10: Initial version

Modern Enhancements to IDENTIFICATION DIVISION

The IDENTIFICATION DIVISION has evolved in modern COBOL standards to support contemporary programming practices while maintaining backward compatibility.

Object-Oriented Identifiers

In object-oriented COBOL, new division headers support class definitions:

cobol
1
2
IDENTIFICATION DIVISION. CLASS-ID. Employee INHERITS FROM Person.

Method Identification

Methods within classes have their own identification:

cobol
1
2
IDENTIFICATION DIVISION. METHOD-ID. calculateSalary.

FUNCTION-ID for User-Defined Functions

For defining reusable functions:

cobol
1
2
IDENTIFICATION DIVISION. FUNCTION-ID. CALCULATE-INTEREST.

FACTORY Paragraph

For defining static class features:

cobol
1
2
3
4
5
IDENTIFICATION 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.

Exercise: Creating an IDENTIFICATION DIVISION

Write an IDENTIFICATION DIVISION for a COBOL program with the following requirements:

  1. The program is named "CUSTOMER-REPORT"
  2. It was written by you on today's date
  3. It belongs to "ACME RETAIL SYSTEMS"
  4. It has a security classification of "CONFIDENTIAL"
  5. Include remarks explaining that the program generates customer purchase history reports

Try to follow the best practices discussed in this lesson.

Test Your Knowledge

1. Which paragraph is mandatory in the IDENTIFICATION DIVISION?

  • AUTHOR
  • PROGRAM-ID
  • DATE-WRITTEN
  • SECURITY

2. What is the maximum length of a program name in standard COBOL?

  • 8 characters
  • 16 characters
  • 30 characters
  • Unlimited characters

3. Which clause would you add to the PROGRAM-ID if the program needs to be able to call itself?

  • INITIAL
  • COMMON
  • RECURSIVE
  • SELF-CALLING

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"?

FAQ

Is the IDENTIFICATION DIVISION still important in modern COBOL?

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.

Do COBOL compilers actually use the information in the optional paragraphs?

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.

Can I use special characters in my PROGRAM-ID?

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.

What's the difference between INITIAL and RECURSIVE in the PROGRAM-ID?

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.