In the Environment Division:

  • Relate items to be used in your program to system-names (Configuration Section).
  • Identify all your files (Input-Output Section).

Configuration Section

Configuration Section is an optional section in which you can:

  • Describe the computer on which the source program is compiled and on which the object program is executed
  • Set status indicators
  • Specify the collating sequence
  • Specify the character to be used for the currency sign
  • Interchange of functions for the comma and the period
  • Specify symbolic characters
  • Specify a user-defined class

The Configuration Section can only appear in the outermost program of a nested program structure. The Configuration Section contains the following paragraphs.

  • SOURCE-COMPUTER Paragraph - This paragraph documents the computer on which your program will be compiled. The WITH DEBUGGING MODE clause specifies that the debugging lines in your program (those statements which are coded with a "D" in column 7) are compiled.
  • OBJECT-COMPUTER Paragraph - The MEMORY SIZE clause documents the amount of main storage your program uses. The PROGRAM COLLATING SEQUENCE clause specifies the collating sequence, associating it with a mnemonic defined in the SPECIAL-NAMES paragraph.
  • SPECIAL-NAMES Paragraph - The SPECIAL-NAMES paragraph allows you to specify special system features, such as the name of the alphabet your program uses for program collating sequence. This paragraph associates system functions with names used in your program, such as ACCEPT/DISPLAY devices. User Programmable Status Indicator (UPSI) switches, and WRITE ADVANCING actions.

Set Status Indicators

User Programmable Status Indicator (UPSI) switches were used on older computers for processing special conditions at run time. Although this method is still supported, two alternative methods of passing status information are:

  • Read data and code conditional processing, based on the value of the data.
  • Pass run-time parameters in the PARM parameter of the EXEC statement in the job control procedure. This preferred technique requires the USING option of the Procedure Division header, a description in the Linkage Section of the records that will contain the parameters passed and the passing of the parameters in run-time JCL.

Specify the Collating Sequence

Using the PROGRAM COLLATING SEQUENCE clause and the ALPHABET clause, you can establish the collating sequence used in the following operations:

  • Nonnumeric comparisons explicitly specified in relation conditions and condition-name conditions
  • HIGH-VALUE and LOW-VALUE settings
  • SORT and MERGE unless overridden by a COLLATING SEQUENCE phrase on the SORT or MERGE statement.

The sequences used can be based on one of these alphabets:

  • EBCDIC (specify NATIVE if the native character set is EBCDIC). This is the default if the ALPHABET clause is omitted.
  • ASCII (specify STANDARD-1).
  • ISO 7-bit code. International Reference Version (specify STANDARD-2).
  • An alteration of the EBCDIC sequence that you define in the SPECIAL-NAMES paragraph.

Each separate SORT or MERGE operation can override the alphabet specified in the PROGRAM COLLATING SEQUENCE clause.

Specify Symbolic Characters

By using the SYMBOLIC CHARACTER clause, you can give symbolic names to any character of the specified alphabet. For example, to give a name to the backspace character (X'16' in the EBCDIC alphabet) you would code:


You use ordinal position to identify the character; position 1 corresponds to character X'OO'.

Specify a User-Defined Class

By using the CLASS clause, you can give a name to a set of characters listed in the clause. For example, name the set of digits by coding: -


The class name can only be referenced in a class condition.

Input-Output Section

You will identify all your files in the Input-Output Section:

  • In the FILE-CONTROL paragraph, describe each file and assign a ddname.
  • In the l-O-CONTROL paragraph, specify information needed for efficient transmission of data between the external medium and your program.

For CICS and online IMS message processing programs (MPP), code only the Environment Division header and, optionally, the Configuration Section. CICS does not allow COBOL definition of files; IMS allows COBOL definition of files only for batch programs.

FILE-CONTROL paragraph

You describe Each File in the FILE-CONTROL paragraph. The following is a FILE-CONTROL entry for a QSAM file:

FILE-CONTROL paragraph

For all files that you process in your VS COBOL II program, you need to code DD statements (JCL) or ALLOCATE commands (TSO) that define the files to the operating system. The following listing illustrates the relationship between then JCL DD statement and the FILE-CONTROL and FD entries in your program.

JCL DD Statement:

JCL DD Statement

JCL DD Statement


  1. The ddname in the DD statement corresponds to the assignment-name in the ASSIGN clause: //OUTFILE DD DSNAME=OUT171
  2. This assignment-name points to the ddname of OUTFILE in the DD statement. ASSIGN TO OUTFILE
  3. When you specify a file in your COBOL FILE-CONTROL entry, the file must be described in an FD entry for file-name. SELECT CUSTOMERFILE FD CUSTOMERFILE

In the FILE-CONTROL paragraph, your ASSIGN clause name can include an 'S-' before the ddname to document that the file is a QSAM file as shown below:

ASSIGN TO [label-] S-name

The ASSIGN clause is required for QSAM files. The ORGANIZATION clause is optional. QSAM files always have sequential organization, and ORGANIZATION IS SEQUENTIAL is the default. The SAME clause in the l-O-CONTROL paragraph is treated as a comment in QSAM. The SAME RECORD AREA clause indicates that two or more files use the same main storage area for processing the current logical record. Do not specify this clause if you have used RECORD CONTAINS 0 CHARACTERS.

In the FILE-CONTROL paragraph, the ASSIGN clause for VSAM sequential files is slightly different from the clause for indexed or relative files:

  • ASSIGN TO [label-] AS-name (Sequential)
  • ASSIGN TO [label-] name (Indexed)
  • ASSIGN TO [label-] name (Relative)

The ASSIGN clause is required for VSAM files. For VSAM indexed and relative files, the ORGANIZATION clause is required. The ORGANIZATION clause for VSAM files can be:

  • ORGANIZATION IS INDEXED - For VSAM indexed files (KSDS) (whether being accessed sequentially or randomly)

The SAME RECORD AREA clause indicates that two or more files use the same main storage area for processing the current logical record. The SAME clause is treated as the SAME RECORD AREA clause. For a VSAM indexed file, your RECORD KEY definition must agree with the definition in the catalog entry. If you are using VSAM indexed files with alternate indexes, your ALTERNATE RECORD KEY definitions must agree with the definitions you have made in the catalog entry. Any password entries you have cataloged should be coded directly after the ALTERNATE RECORD KEY phrase. Specify WITH DUPLICATES only if your alternate index was cataloged as having duplicate keys. You cannot change your strategy here in your COBOL program, unless you have already taken care of the catalog entries.

Using the FILE STATUS clause, you can set up error-handling procedures for use when a nonzero file status code is returned. Coding the FILE STATUS clause for each defined file and coding a test for the file status key value after each I/O statement is strongly recommended. For VSAM files, you can use a second data-name in the FILE STATUS clause to get VSAM return code, component code and reason code information. Both data-names must be defined in the Data Division.

  • FILE STATUS IS data-name-1 [data-name-2]

The file-name you specify in your SELECT sentence is used as a constant throughout your COBOL program, while the name of the file (also called dataset) on the DD statement can be associated with a different file at execution.

Changing a file-name in your COBOL program requires changing input/output statements and recompiling the program. In contrast, you can change the DSNAME in the DD statement at execution. As an example, consider a COBOL program that might be used in exactly the same way for several different master files. It contains this SELECT sentence:

SELECT sentence

The three possible input files are MASTER!, MASTER2, and MASTER3. Therefore, one of the following DD statements is coded in the job step that calls for program execution:

DD statements is coded in the job step that calls for program execution

Any reference within the program to MASTERA is a reference to the file assigned to DSNAME. The ddname-portion of the assignment-name that appears in the ASSIGN clause and the ddname of the DD statement must always be the same. You can vary the file itself in the DSNAME given in the DD statement. The file-name that follows the SELECT statement (in the example MASTER) must "be the same as the FD file­name entry.

The APPLY WRITE-ONLY clause makes optimum use of buffer and device space when creating a sequential file with blocked V-mode records. With APPLY WRITE-ONLY, a buffer is truncated only when the next record does not fit in the unused remainder of we buffer, allowing for a performance savings since this will generally result in a reduction of the number of l/O's to the output device. Also note that the AWO compiler option has the effect of putting the APPLY WRITE-ONLY clause on all eligible files. The NOAWO compiler option does not affect files for which the APPLY WRITE-ONLY clause has been specified.

Without APPLY WRITE-ONLY, a buffer is truncated when there is not enough space remaining in it to accommodate the maximum size record. This clause has meaning only when the file is opened as OUTPUT or EXTEND and has standard sequential organization.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

IBM Mainframe Topics