IDENTIFICATION DIVISION
- IDENTIFICATION DIVISION should be coded as the first division in the COBOL program.
- It provides metadata about the program, such as its name, author, installation, and other descriptive information used to uniquely identify it.
- It is a mandatory division in the COBOL program.
Syntax -
----+----1----+----2----+----3----+----4----+----5----+
IDENTIFICATION DIVISION.
PROGRAM-ID. NameOfProgram [IS COMMON [INITIAL]|
IS INITIAL [COMMON]] PROGRAM.
[AUTHOR. NameOfProgrammer.]
[INSTALLATION. Development-center.]
[DATE-WRITTEN. mm/dd/yy.]
[DATE-COMPILED. mm/dd/yy. HH:MM:SS.]
[SECURITY. Program-type.]
Notes -
- IDENTIFICATION DIVISION and PROGRAM-ID entries are mandatory.
- The remaining entries, AUTHOR, INSTALLATION, DATE-WRITTEN, DATE-COMPILED, and SECURITY, are optional and can appear in any order based on the requirement.
- All entries, including the IDENTIFICATION DIVISION entry, should start in Area-A.
Parameters -
PROGRAM-ID. NameOfProgram. -
- PROGRAM-ID entry is used to specify the program name.
- It is mandatory and should be the first entry in the IDENTIFICATION DIVISION.
- The member name (PDS name/name in source library) and the NameOfProgram may differ in some cases. However, it is advised that both should be the same to avoid confusion.
NameOfProgram -
It is a user-defined alphanumeric word that identifies the program uniquely.
Rules -
- The NameOfProgram length can be up to 8 characters.
- Only the hyphen, underscore, digits 0-9, and alphabetic characters are allowed.
- At least one and the first character should be alphabetic.
- The hyphen can't be the first or last character and should not be a figurative constant.
Examples -
NameOfProgram (Invalid) | NameOfProgram (Valid) |
---|---|
12345 | A2345 |
9A-23 | A1B23 |
9A_66 | A9_66 |
-NEWPROG | N-EWPROG |
NEWPROG- | NEWPRO-G |
COMMON -
The COMMON clause with the NameOfProgram is used to specify that the program is coded within another program. The COMMON clause uses only in nested programs.
Examples -
----+----1----+----2----+----3----+----4----+----5----+
IDENTIFICATION DIVISION.
PROGRAM-ID. IDMAINPR.
AUTHOR. MTH.
PROCEDURE DIVISION.
....
STOP RUN.
IDENTIFICATION DIVISION.
PROGRAM-ID. IDNESTPR IS COMMON.
AUTHOR. MTH.
PROCEDURE DIVISION.
....
STOP RUN.
END PROGRAM IDNESTPR.
END PROGRAM IDMAINPR.
INITIAL -
INITIAL clause is used to specify all nested programs contained within the main program are set to their initial state when the main program is called. The INITIAL clause is used only in the main program (not the nested program).
Examples -
----+----1----+----2----+----3----+----4----+----5----+
IDENTIFICATION DIVISION.
PROGRAM-ID. IDMAINPR IS INITIAL.
AUTHOR. MTH.
PROCEDURE DIVISION.
....
STOP RUN.
IDENTIFICATION DIVISION.
PROGRAM-ID. IDNESTPR.
AUTHOR. MTH.
PROCEDURE DIVISION.
....
STOP RUN.
END PROGRAM IDNESTPR.
END PROGRAM IDMAINPR.
AUTHOR. NameOfProgrammer. -
AUTHOR is used to specify the programmer name who has written the program. It is an optional entry and is used for documentation.
INSTALLATION. Development-center. -
INSTALLATION entry is used to specify the location or company name where it the installed. It is an optional entry and is used for documentation.
DATE-WRITTEN. mm/dd/yy. -
DATE-WRITTEN entry is used to specify the actual date of the program written. It is an optional entry and is used for documentation.
DATE-COMPILED. mm/dd/yy. HH:MM:SS. -
- DATE-COMPILED entry is used to specify the actual compilation date of the program written in the load module.
- If an entry is coded, it is replaced with the compilation date of the program. If the entry is ignored, the compiler adds the current date to the DATE-COMPILED line.
- It is an optional paragraph and is used for documentation.
SECURITY. Program-type. -
SECURITY entry is used to specify the program confidentiality level to understand developers or others working on the program. It is an optional entry and is used for documentation.
Comment entries -
All the user-defined words specified with IDENTIFICATION DIVISION entries are comment entries. The comment entry should code in Area-B in one or more lines. The comment entries are as follows -
- NameOfProgram.
- NameOfProgrammer.
- Development-center.
- mm/dd/yy.
- mm/dd/yy. HH:MM:SS.
- Program-type.
Example - Explaing about IDENTIFICATION DIVISION entries.