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 are the formats for the FILE-CONTROL paragraph:
The table below lists the different type of files available to programs and methods.
| File organization | File system |
|---|---|
| Sequential | VSAM1, SdU, SFS, STL, RSD2, DB2 |
| Relative | VSAM1, SdU, SFS, STL, DB2 |
| Indexed | VSAM1, SdU, SFS, STL, DB2 |
| Line sequential | Native |
|
|
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 >>-SELECT--+----------+--file-name-1----------------------------> '-OPTIONAL-' .-------------------. V | >--ASSIGN--+-+----+----assignment-name-1-+-+--------------------> | '-TO-' | '-USING--data-name-9------------' >--+------------------------------+-----------------------------> '-RESERVE-- integer--+-------+-' +-AREA--+ '-AREAS-' >--+--------------------------------------+---------------------> '-+----------------------+--SEQUENTIAL-' '-ORGANIZATION--+----+-' '-IS-' >--+-------------------------------------------------+----------> '-PADDING--+-----------+--+----+--+-data-name-5-+-' '-CHARACTER-' '-IS-' '-literal-2---' >--+-------------------------------------------------+----------> '-RECORD DELIMITER--+----+--+-STANDARD-1--------+-' '-IS-' '-assignment-name-2-' >--+--------------------------------------+---------------------> '-ACCESS--+------+--+----+--SEQUENTIAL-' '-MODE-' '-IS-' >--+-------------------------------+----------------------------> '-PASSWORD--+----+--data-name-6-' '-IS-' >--+--------------------------------------------------------+---> '-+------+--STATUS--+----+--data-name-1--+-------------+-' '-FILE-' '-IS-' '-data-name-8-' >--.-----------------------------------------------------------><
Format 2: indexed-file-control-entry >>-SELECT--+----------+--file-name-1----------------------------> '-OPTIONAL-' .-------------------. V | >--ASSIGN--+-+----+----assignment-name-1-+-+--------------------> | '-TO-' | '-USING--data-name-9------------' >--+-----------------------------+--+----------------------+----> '-RESERVE--integer--+-------+-' '-ORGANIZATION--+----+-' +-AREA--+ '-IS-' '-AREAS-' >--INDEXED--+------------------------------------------+--------> '-ACCESS--+------+--+----+--+-SEQUENTIAL-+-' '-MODE-' '-IS-' +-RANDOM-----+ '-DYNAMIC----' >--RECORD--+-----+--+----+--data-name-2-------------------------> '-KEY-' '-IS-' .-----------------. V | >--+-------------------------------+----+-------------+-+-------> '-PASSWORD--+----+--data-name-6-' '-| entry 1 |-' '-IS-' >--+--------------------------------------------------------+---> '-+------+--STATUS--+----+--data-name-1--+-------------+-' '-FILE-' '-IS-' '-data-name-8-' >--.----------------------------------------------------------->< entry 1 |--ALTERNATE--+--------+--+-----+--+----+--data-name-3----------> '-RECORD-' '-KEY-' '-IS-' >--+----------------------+-------------------------------------> '-+------+--DUPLICATES-' '-WITH-' >--+-------------------------------+----------------------------| '-PASSWORD--+----+--data-name-7-' '-IS-'
Format 3: relative-file-control-entry >>-SELECT--+----------+--file-name-1----------------------------> '-OPTIONAL-' .-------------------. V | >--ASSIGN--+-+----+----assignment-name-1-+-+--------------------> | '-TO-' | '-USING--data-name-9------------' >--+------------------------------+--+----------------------+---> '-RESERVE-- integer--+-------+-' '-ORGANIZATION--+----+-' +-AREA--+ '-IS-' '-AREAS-' >--RELATIVE-----------------------------------------------------> >--+--------------------------------------------------------------------------------------+--> '-ACCESS--+------+--+----+--+-SEQUENTIAL--+----------------------------------------+-+-' '-MODE-' '-IS-' | '-RELATIVE--+-----+--+----+--data-name-4-' | | '-KEY-' '-IS-' | '-+-RANDOM--+--RELATIVE--+-----+--+----+--data-name-4----' '-DYNAMIC-' '-KEY-' '-IS-' >--+-------------------------------+----------------------------> '-PASSWORD--+----+--data-name-6-' '-IS-' >--+--------------------------------------------------------+---> '-+------+--STATUS--+----+--data-name-1--+-------------+-' '-FILE-' '-IS-' '-data-name-8-' >--.-----------------------------------------------------------><
Format 4: line-sequential-file-control-entry >>-SELECT--+----------+--file-name-1----------------------------> '-OPTIONAL-' .-------------------. V | >--ASSIGN--+-+----+----assignment-name-1-+-+--------------------> | '-TO-' | '-USING--data-name-9------------' >--+----------------------+--LINE SEQUENTIAL--------------------> '-ORGANIZATION--+----+-' '-IS-' >--+--------------------------------------+---------------------> '-ACCESS--+------+--+----+--SEQUENTIAL-' '-MODE-' '-IS-' >--+--------------------------------------------------------+---> '-+------+--STATUS--+----+--data-name-1--+-------------+-' '-FILE-' '-IS-' '-data-name-8-' >--.-----------------------------------------------------------><