FILE-CONTROL paragraph

The FILE-CONTROL paragraph associates each file in the COBOL program with an external data set, and specifies file organization, access mode, and other information.

The following formats are for the FILE-CONTROL paragraph:

  • Sequential file entries
  • Indexed file entries
  • Relative file entries
  • Line-sequential file entries

The following table lists the different type of files available to programs and methods.

Table 1. Types of files
File organization Access method
Sequential QSAM, VSAM1
Relative VSAM1
Indexed VSAM1
Line sequential2 Text stream I-O
  1. VSAM does not support z/OS UNIX files.
  2. Line-sequential support is limited to z/OS UNIX files.

The FILE-CONTROL paragraph begins with the word FILE-CONTROL followed by a separator period. It must contain one and only one entry for each file described in an FD or SD entry in the DATA DIVISION.

Within each entry, the SELECT clause must appear first. The other clauses can appear in any order, except that the PASSWORD clause for indexed files, if specified, must immediately follow the RECORD KEY or ALTERNATE RECORD KEY data-name with which it is associated.

The name component of assignment-name-1 cannot contain an underscore.

Format 1: sequential-file-control-entry

Read syntax diagramSkip visual syntax diagramSELECTOPTIONALfile-name-1ASSIGN TOassignment-name-1 RESERVE integerAREAAREASORGANIZATIONISSEQUENTIALPADDINGCHARACTERISdata-name-5literal-2RECORD DELIMITERISSTANDARD-1assignment-name-2ACCESSMODEISSEQUENTIALPASSWORDISdata-name-6FILESTATUSISdata-name-1data-name-8.

Format 2: indexed-file-control-entry

Read syntax diagramSkip visual syntax diagramSELECTOPTIONALfile-name-1ASSIGN TOassignment-name-1 RESERVEintegerAREAAREASORGANIZATIONISINDEXEDACCESSMODEISSEQUENTIALRANDOMDYNAMICRECORDKEYIS data-name-2 PASSWORDISdata-name-6entry 1FILESTATUSISdata-name-1data-name-8.
entry 1
Read syntax diagramSkip visual syntax diagramALTERNATERECORDKEYISdata-name-3WITHDUPLICATESPASSWORDISdata-name-7

Format 3: relative-file-control-entry

Read syntax diagramSkip visual syntax diagramSELECTOPTIONALfile-name-1ASSIGN TOassignment-name-1 RESERVE integerAREAAREASORGANIZATIONISRELATIVEACCESSMODEISSEQUENTIALRELATIVEKEYISdata-name-4RANDOMDYNAMICRELATIVEKEYISdata-name-4PASSWORDISdata-name-6FILESTATUSISdata-name-1data-name-8.

Format 4: line-sequential-file-control-entry

Read syntax diagramSkip visual syntax diagramSELECTOPTIONALfile-name-1ASSIGN TOassignment-name-1 ORGANIZATIONIS LINE SEQUENTIALACCESSMODEISSEQUENTIALFILESTATUSISdata-name-1.