1. File Description Entry
The file description entry represents the start of descriptions for files defined in the SELECT clause of the environment division. A file name must be specified after FileDescription (FD) or SortFileDescription (SD).
-
Format 1
File Description Entry Format 1
File Description Entry Format 1 - Clause1
File Description Entry Format 1 - Clause2 -
Format 2
File Description Entry Format 2
File description entry Format 2 - Clause -
Format 3
File Description Entry Format 3
File Description Entry Format 3 - Cluase -
Format 4
File Description Entry Format 4
File Description Entry Format 4 - Clause1
File Description Entry Format 4 - Clause2
1.1. File Section
The file section includes a level-indicator (FD, SD) for each input and output file.
| Item | Description |
|---|---|
file-name |
Must be specified after a level-indicator (FD, SD) in the relevant SELECT clause. file-name must be unique in a program. |
FD (format 1, 2, and 3) |
The file section must include the FD entry for all files except for sort/merge files. The last clause in the FD entry must be followed by a period (.). |
SD (format 4) |
The files section must include the SD entry for sort/merge files. The last clause in the SD entry must be followed by a period (.). |
|
A record in the file section must be an alphanumeric group item or an alphabetical, alphanumeric, DBCS, or numeric elementary data item. |
1.1.1. EXTERNAL Clause
The EXTERNAL clause is specified so that different programs can share files in a COBOL program’s run unit.
1.1.2. GLOBAL Clause
The GLOBAL clause is specified so that a program and its nested programs can share files.
1.1.3. BLOCK CONTAINS Clause
The BLOCK CONTAINS clause is specified to define the physical length of a record. It is syntax checked, but does not affect the program execution.
1.1.4. RECORD Clause
When the RECORD clause is used, the record length must be specified with the number of bytes needed to store the record regardless of the USAGE of the data items specified in the record. For example, for a record that consists of 10 DBCS characters, the RECORD clause must be described as RECORD CONTAINS 20 CHARACTERS. If the RECORD clause is omitted, the compiler determines the record lengths based on the record descriptions.
Format 1
Format 1 specifies the length of fixed-length records.
| Item | Description |
|---|---|
integer-3 |
Specifies the record length with a positive integer. |
Format 2
Format 2 specifies the length of fixed-length or variable-length records.
| Item | Description |
|---|---|
integer-4 |
Specifies the minimum value of the record length with a positive integer. |
integer-5 |
Specifies the maximum value of the record length with a positive integer. |
|
If integer-4 and integer-5 are the same, the record has a fixed length. |
Format 3
Format 3 specifies the length of variable-length records.
| Item | Description |
|---|---|
integer-6 |
Specifies the minimum value of the record length with a positive integer. |
integer-7 |
Specifies the maximum value of the record length with a positive integer. |
data-name-1 |
Must be an elementary data item of the unsigned integer type. data-name-1 must contain the record length before a RELEASE, REWRITE, or WRITE statement can be executed. data-name-1 is not changed due to the execution of a DELETE, RELEASE, REWRITE, START, or WRITE statement or the failed execution of a READ or RETURN statement. data-name-1 is changed to the record length that was just read if a READ or RETURN statement is successfully executed. |
1.1.5. LABEL RECORDS Clause
The LABEL RECORDS clause is specified to define whether labels exist. It is syntax checked, but does not affect the program execution.
1.1.6. VALUE OF Clause
The VALUE OF clause is specified to define a label record related to the file. It is syntax checked, but does not affect the program execution.
1.1.7. DATA RECORDS Clause
The DATA RECORDS clause is specified to define a data name related to the file. It is syntax checked, but does not affect the program execution.
1.1.8. LINAGE Clause
The LINAGE clause specifies the logical page size by the number of lines. It optionally specifies the start position of the footing area and the top and bottom margins.
The LINAGE clause is available for sequential files opened with OUTPUT or EXTEND.
| Item | Description |
|---|---|
data-name-5, integer8 |
Specifies the number of lines in a logical page. The page area represented by the lines is called the page body. This value must be greater than zero. |
WITH FOOTING AT |
integer-9 or the value of data-name-6 specifies the first line number of the footing area in the page body. The value must be greater than zero and not greater than the last line number of the page body. |
LINES AT TOP |
integer-10 or the value of data-name-7 specifies the top margin of the logical page. This value must be equal to or greater than zero. |
LINES AT BOTTOM |
integer-11 or the value of data-name-8 specifies the bottom margin of the logical page. This value must be equal to or greater than zero. |
Descriptions for each part of the LINAGE clause are as follows:
-
If the LINES AT TOP or LINES AT BOTTOM phrase is not specified, the default value is zero.
-
If the FOOTING phrase is omitted, the value is the same as that of the page body (integer-8 or data-name-5).
-
If the values of integer-8, integer-9, integer-10, and integer-11 are specified when an OPEN OUTPUT statement is executed, they are used to configure the logical pages while the program is executing.
-
If the values of data-name-5, data-name-6, data-name-7, and data-name-8 are specified when an OPEN OUTPUT statement is executed, they configure the first logical page. When a page is turned due to a WRITE statement being executed, the values of data-name-5, data-name-6, data-name-7, and data-name-8 configure the next new logical page.
-
The LINAGE clause in an SD is syntax checked, but does not affect the execution of the program.
-
A LINAGE-COUNTER special register exists for each file.