Identification division in cobol

148 Views


The Identification Division must be the first division in every COBOL source program. It names the program and may include the date the program was written, the date of compilation, and other such documentary information about the program.

The first paragraph of the Identification Division must be the PROGRAM-ID paragraph. The other paragraphs are optional, but, when written, must appear in the order shown in the format.

The abbreviation ID DIVISION may be substituted for the standard division header, and the optional paragraphs may be in any order. Note: The SEU Syntax Checker requires that the first sentence of the following paragraph headers begin on the same line as the paragraph header:

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

Figure shows how the coding for the Identification Division should look.

PROGRAM-ID Paragraph

The PROGRAM-ID paragraph specifies the name of the COBOL program. For an outermost program, it can also specify the name of the program object (*PGM) or module object (*MODULE), or both. It is required and must be the first paragraph in the Identification Division.

The name by which the program object is known to the system can be overridden by the PGM parameter of the CRTBNDCBL command. The name by which the module object is known can be overridden by the MODULE parameter of the CRTCBLMOD command. 

program-name

A user-defined word that identifies your program or module object to the system. For program and module objects, only the first 10 characters of program-name are used as the identifying name of the object. For an ILE procedure name, the first 250 characters of program-name are used. If the *MONOPRC option is specified on the CRTBNDCBL or CRTCBLMOD command, the first character of program-name is forced to be alphabetic; if it is numeric, it is converted as follows:

0                 to J

1 through 9 to A through I

If a hyphen is in positions 2 through 10, it is converted to zero (0).

literal

Must be a nonnumeric literal. A nonnumeric literal without the enclosing delimiters becomes the program-name. The same rules apply for forming module, program, and procedure names as defined above under program-name. If the *MONOPRC option is specified, however, lowercase letters in the literal are converted to their uppercase equivalents.

RECURSIVE Clause

The RECURSIVE clause is an optional clause that allows COBOL programs to be recursively re-entered. This clause specifies that the program and any program contained within it are recursive. ILE COBOL allows the RECURSIVE clause in a nested program. As well, recursive programs will be able to contain a nested subprogram. Program-name-1 can be recursively re-entered while a previous invocation is still active if the RECURSIVE clause is specified. An active program cannot be recursively re-entered if the RECURSIVE clause is not specified.

The Working-Storage Section of a recursive program defines storage that is statically allocated and initialized on the first entry to a program, and is available in a last-used state to any of the recursive invocations. The Local-Storage Section of a recursive program (as well as a non-recursive program) defines storage that is automatically allocated, initialized, and deallocated on a per-invocation basis.

The following language elements are not supported in a recursive program:

  • ALTER
  • GO TO without a specified procedure name;
  • RERUN;
  • SEGMENTATION
  • USE FOR DEBUGGING

The RECURSIVE clause shall not be specified if any program that directly or indirectly contains this program is an inital program.

PROGRAM-ID Paragraph

COMMON Clause

The COMMON clause allows the program named by program-name to be called by its siblings and by programs contained within the siblings. The COMMON clause can be used only in nested programs.

INITIAL Clause

Specifies that when program-name is called, program-name and any programs contained within it are set to their initial state. (All working storage items are reset to their initial values and all INTERNAL files are closed.)

A program is set to its initial state:

  • The first time the program is called in a run unit
  • Every time the program is called, if it possesses the INITIAL attribute
  • The first time the program is called after the execution of a CANCEL statement referencing the program or a CANCEL statement referencing a program that directly or indirectly contains the program
  • The first time the program is called after the execution of a CALL statement referencing a program that possesses the INITIAL attribute, and that directly or indirectly contains the program.

For example, if program A calls program B, and program B has the INITIAL attribute and also contains program C, program C will be set to its initial state the first time that it is called after A called B.

Optional Paragraphs

These optional paragraphs in the Identification Division may be omitted.

AUTHOR Name of the author of the program. It is syntax checked only.

INSTALLATION Name of the company or location. It is syntax checked only.

DATE-WRITTEN Date the program was written. It is syntax checked only.

DATE-COMPILED Date the program was compiled.

SECURITY Level of confidentiality of the program.

comment-entry

The comment-entry in any of the optional paragraphs may be any combination of characters from the character set of the computer. Do not confuse the comment-entry with a comment line. (The latter is indicated by a slash or asterisk in the indicator area.)
The comment-entry is written in Area B on one or more lines. The SEU Syntax Checker, however, requires that the first sentence begin on the same line as the paragraph header.

Comment-entries serve only as documentation; they do not affect the meaning of the program. A hyphen in the indicator area (column 7) is not permitted in comment-entries.

The paragraph name DATE-COMPILED and any comment-entry associated with it are replaced during compilation with a paragraph of the form:

DATE-COMPILED. current

The first eight lines of the comment-entry in the SECURITY paragraph will form the copyright information in the created module object.

A comment-entry may contain the *CBL, *CONTROL, EJECT, SKIP1, SKIP2, SKIP3, or TITLE statements anywhere on the line.

Optional Paragraphs

Post Comments