COBOL - Environment Division
The identification division gives introduction about the program. Now we need to define the Machine dependent details for our program. These details are given in ENVIRONMENT DIVISION. It is an optional division.
The ENVIRONMENT DIVISION must follow the IDENTIFICATION DIVISION in the COBOL program. Among all the divisions this one is the most machine dependent division. The computer and all the peripheral devices required by the program are described in this division.
The Environment Division consists of 2 sections:
- The Configuration Section
- The Input-Output Section
Given below is the example for Configuration section:
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-I.
OBJECT-COMPUTER. IBM-I.
SPECIAL-NAMES. C01 IS TOP-OF-PAGE. |
The paragraphs in the Configuration Section are given in the succeeding lines:
- SOURCE-COMPUTER Paragraph:
- The Computer on which the source program is to be compiled.
- The Computer Name in a system name in the form of IBM-3090
- OBJECT-COMPUTER Paragraph:
- Identifies the computer on which the object program is to be executed.
- The PROGRAM COLLATING SEQUENCE clause specifies that the collating sequence used in the program is the collating sequence associated with the specified alphabet-name, which must be defined in SPECIAL-NAMES Paragraph.
- The program collating sequence is used to determine the truth value of following non-numeric comparisons:
- Those explicitly specified in relation conditions.
- Those explicitly specified in condition-name conditions.
- When the PRORAM COLLATING SEQUENCE clause is omitted, the EBCDIC Collating sequence is used.
- The SPECIAL NAMES paragraph: Can have entries, which are implementer dependent. Like the CURRENCY can be changed or the DECIMAL POINT can be COMMA.
Input-Output Section:
This section is primarily used to code the FILE-CONTROL paragraph.
FILE-CONTROL: This paragraph is used to associate the files to be used in the program with specific I/O devices.
For example:
INPUT-OUTPUT SECTION.
FILE CONTROL.
SELECT INPUT-FILE ASSIGN TO INPUT-FL.
|
In the example, INPUT-FILE is the name of the file to be used throughout the program. INPUT-FL is a system name, which will be used to link the file to something in the operating system. The method of such connection varies from system to system.
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!