FILE-CONTROL paragraph

The FILE-CONTROL paragraph associates each file in the COBOL program with an external file, 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 table below lists the different type of files available to programs.

Table 1. Types of files
File organization File system
Sequential SFS, STL, RSD1, Db2®, QSAM2, MONGO
Relative SFS, STL, Db2, MONGO
Indexed SFS, STL, Db2, MONGO
Line sequential LSQ
  1. The RSD file system supports fixed or variable-length record sequential files.
  2. The QSAM file system supports fixed, variable, and spanned records.
  3. If you specify the SdU file type, it will be handled as if you specified the STL file.

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.

The underscore is allowed in the external-file-name component of assignment-name-1.

Format 1: sequential-file-control-entry

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

Format 2: indexed-file-control-entry

Read syntax diagramSkip visual syntax diagramSELECTOPTIONALfile-name-1ASSIGN TOassignment-name-1USINGdata-name-9 RESERVEintegerAREAAREASORGANIZATIONISINDEXEDACCESSMODEISSEQUENTIALRANDOMDYNAMICRECORDKEYIS data-name-2record-key-name-1SOURCEIS=data-name-10 PASSWORDISdata-name-6entry 1FILESTATUSISdata-name-1data-name-8WITHLOCKONMULTIPLERECORDRECORDS.
entry 1
Read syntax diagramSkip visual syntax diagramALTERNATERECORDKEYISdata-name-3record-key-name-2SOURCEIS=data-name-11WITHDUPLICATESPASSWORDISdata-name-7
Restriction: record-key-name is supported for STL file system only.

Format 3: relative-file-control-entry

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

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

Read syntax diagramSkip visual syntax diagramSELECTOPTIONALfile-name-1ASSIGN TOassignment-name-1USINGdata-name-9 ORGANIZATIONIS LINE SEQUENTIALACCESSMODEISSEQUENTIALFILESTATUSISdata-name-1data-name-8.