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 are the formats for the FILE-CONTROL paragraph:
The table below lists the different type of files available to programs and methods.
| File organization | Access method |
|---|---|
| Sequential | QSAM, VSAM1 |
| Relative | VSAM1 |
| Indexed | VSAM1 |
| Line sequential2 | Text stream I-O |
|
|
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.
Format 1: sequential-file-control-entry >>-SELECT--+----------+--file-name-1----------------------------> '-OPTIONAL-' .-------------------. V | >--ASSIGN----+----+----assignment-name-1-+----------------------> '-TO-' >--+-----------------------------+------------------------------> '-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-' >--+-----------------------------+--+----------------------+----> '-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-' >--+-----------------------------+--+----------------------+----> '-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-' >--+----------------------+--LINE SEQUENTIAL--------------------> '-ORGANIZATION--+----+-' '-IS-' >--+--------------------------------------+---------------------> '-ACCESS--+------+--+----+--SEQUENTIAL-' '-MODE-' '-IS-' >--+---------------------------------------+--.---------------->< '-+------+--STATUS--+----+--data-name-1-' '-FILE-' '-IS-'