COBOL

ENVIRONMENT DIVISION

The second division occurring within a COBOL (sub)program is the ENVIRONMENT DIVISION, which supplies installation-specific information regarding what computer equipment is needed to run the program.

Its two sections are the CONFIGURATION SECTION, which is just about useless, and the INPUT-OUTPUT SECTION, in which is established the mapping from file names used in the program to actual files on the computer system. Specifically, this occurs in the FILE-CONTROL paragraph.

A typical example of what appears in this division is

      ENVIRONMENT DIVISION.
      INPUT-OUTPUT SECTION.
      FILE-CONTROL.
          SELECT Data-File ASSIGN TO "data.dat".
          SELECT Output-File ASSIGN TO SYS$OUTPUT.  

Here, we have mapped the file referred to in the program by the data-name Output-File to standard output (which, in the VMS operating system, is indicated by SYS$OUTPUT). Similarly, the file referred to inside the program as Data-File is mapped to the file with name data.dat on the computer system. It is possible to map internal files to programmer-defined logical names (which themselves can be linked to the names of actual files via scripts, or command files, or JCL, or whatever), thereby making the program more flexible (e.g., by allowing it to access different files each time it is run, without having to recompile it).

Notice that a SELECT clause may not intersect with "Area A"; that is, they must be indented to at least the fifth position on the line. (Area A includes columns 1-4 on each line, which only certain syntactic entities may occupy.)

For more information regarding the ENVIRONMENT DIVISION, see page 105 of Comprehensive COBOL.