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 are the formats for the FILE-CONTROL paragraph:
- Sequential file entries
- Indexed file entries
- Relative file entries
- Line-sequential file entries
Types of files (Table 6) lists the different type of files
available to programs and methods.
Table 6. Types of files
| File organization |
Access method |
| Sequential |
Btrieve, STL, RSD |
| Relative |
Btrieve, STL |
| Indexed |
Btrieve, STL |
| 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.
| Format 1: sequential-file-control-entries |
 >>-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-entries |
 >>-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-entries |
 >>-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-entries |
 >>-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-'
>--.-----------------------------------------------------------><
|
|