File Section
The File Section contains the descriptions of data items used in sequential, relative, indexed, and sort files.
General Format:
[ FILE SECTION. ]
[ file-descripiton ]…
[ fd-data-level fd-data-description ] …
[ sort-description ]…
[ sd-data-level sd-data-description ] …
The General Formats for the File Description and Sort Description are below:
General Rules:
- The File Section contains the File Descriptions and Sort Descriptions.
- Every File Description and Sort Description must have a corresponding
SELECT
statement in the Environment Division.
File Description
The File Descripiton describes the characteristics of a sequential, relative, or indexed file.
General Format:
FD file-name [ IS { EXTERNAL } ]
{ GLOBAL }
[BLOCK CONTAINS integer-1 [TO integer-2 ] {RECORDS } ]
{CHARACTERS}
[ CODE-SET IS alphabet-name ]
[RECORD { CONTAINS int-1 [TO int-2 ] CHARACTERS } ]
[ IS VARYING IN SIZE [ FROM int-3 ] [ TO int-4 ] CHARACTERS ]
[ DEPENDING ON record-depending ]
[ MODE IS VARIABLE [RECORD VARYING FROM 1]]
[ LABEL RECORDS [ARE] {STANDARD} ]
{OMITTED }
[ VALUE OF { LABEL } IS valueof-name ]
{ FILE-ID }
[ { DATA RECORD IS } {record-name} ... ]
{ DATA RECORDS ARE }
[ LINAGE IS page-size LINES
[ WITH FOOTING AT footing-line ]
[ LINES AT TOP top-lines ]
[ LINES AT BOTTOM bottom-lines ] ] .
[ RECORDING MODE IS { F } ]
{ V }
{ U }
{ S }
[ { REPORT IS } report-name ]
{ REPORTS ARE }
General Rules:
file-name
described in a File Description (FD), may be referenced byOPEN
,CLOSE
,START
,READ
, andUNLOCK
statements- The General Rules for the File Description clauses are described below.
Sort Description
The SORT
Description describes the characteristics of a SORT
file.
General Format:
SD file-name
[RECORD { CONTAINS int-1 [TO int-2 ] CHARACTERS } ]
[ IS VARYING IN SIZE [ FROM int-3 ] [ TO int-4 ] CHARACTERS ]
[ DEPENDING ON record-depending ]
[ { DATA RECORD IS } {record-name} ... ]
{ DATA RECORDS ARE }
[ VALUE OF FILE-ID IS valueof-name ]
General Rules:
file-name
described in a Sort Description (SD), may only be referenced by SORT
and MERGE
statements.
The General Rules for the Sort Description clauses are described below.
File Section Clauses
Block Contains Clause
The BLOCK CONTAINS
clause is recognized, and syntax is validated. However, the BLOCK CONTAINS
clause is otherwise treated as commentary.
General Format:
[BLOCK CONTAINS integer-1 [TO integer-2 ] {RECORDS } ]
{CHARACTERS}
Syntax:
integer-1
is an integerinteger-2
is an integer that is greater thaninteger-1
.
General Rules:
There are no General Rules.
Code-Set Clause
The CODE-SET
clause associates an ALPHABET
with a sequential file.
General Format:
[ CODE-SET IS alphabet-name ]
Syntax:
- The
CODE-SET
clause may only be applied toSEQUENTIAL
files. Alphabet-name
is the name of an alphabet de scribed inSPECIAL-NAMES
.- The
CODE-SET
clause requires that all data items in the record description beUSAGE DISPLAY
.
General Rules:
- The
CODE-SET
clause usesalphabet-name
to represent the character set in which the file data is stored. - Usage of the
CODE-SET
clause causes data conversion between the native character set and the character set described byalphabet-name
to occur on input and output FileI/O
operations.
Data Records Clause
The DATA RECORDS
clause names the 01-level record names in a file.
The DATA RECORDS
clause is is recognized, and syntax is validated. However, the DATA RECORDS
clause is otherwise treated as commentary.
General Format:
[ { DATA RECORD IS } {record-name} ... ]
{ DATA RECORDS ARE }
Syntax:
record-name
(s) are the 01-level record names of the file.
General Rules:
There are no General Rules.
External Clause
The EXTERNAL
clause allows an file to be shared between programs in the same execution instance.
General Format:
IS EXTERNAL
General Rules:
- A file declared
IS EXTERNAL
shares itsOPEN
, andCLOSE
state,READ
/WRITE
buffers, and file pointer state between separately compiled programs. - All programs using the file must have the same
SELECT
andFD
declarations for the file, and allFD
declarations must contain theIS EXTERNAL
phrase. - A file description or data item may be declared
IS EXTERNAL
andIS GLOBAL
simultaneously. GLOBAL Clause
The Global clause
General Format:
IS GLOBAL
General Rules:
- A file declared
IS GLOBAL
shares itsOPEN
, andCLOSE
state,READ
/WRITE
buffers, and file pointer state between a program and the nested programs it contains, and which together form a single compilation unit. - The
GLOBAL
clause indicates that a data item, and any data items or conditions or indexes subordinate to it, may be accessed by any of the programs in a compilation unit. - The
GLOBAL
clause may only be used with data items having an 01 data level. - The
GLOBAL
clause may be used in the File Section, Working-Storage Section, Local Storage Section, and Linkage Section. - A file description or data item may be declared
IS EXTERNAL
andIS GLOBAL
simultaneously.
Label Records Clause
The LABEL RECORDS
clause is recognized, and syntax is validated. However, the LABEL RECORDS
clause is otherwise treated as commentary.
General Format:
[ LABEL RECORDS [ARE] {STANDARD} ]
{OMITTED }
General Rules:
There are no General Rules.
Linage Clause
The LINAGE
clause causes an internal counter to be maintained by print files which allows for the trapping of the END-OF-PAGE
condition.
General Format:
[ LINAGE IS page-lines LINES
[ WITH FOOTING AT footing-line-number ]
[ LINES AT TOP number-top-lines ]
[ LINES AT BOTTOM number-bottom-lines ] ] .
Syntax:
page-lines
is a numeric data item, or integer literal.footing-line
number is a numeric data item, or integer literal.number-top-lines
is a numeric data item or integer literal.number-bottom-lines
is a numeric data item or integer literal.
General Rules:
page-lines
is maintained as an internal counter. When counter reachespage-lines
, theend-of-page
condition is trigge red, and can be trapped by theWRITE
statement.- The
LINES AT TOP number-top-lines
clause is the number of line feeds that are written after advancing a page. - The
LINES AT BOTTOM number-bottom-lines
clause is the number of line feeds that are written before advancing a page. - The
FOOTING AT
footing ine number describes an area of the report above theLINES
atBOTTOM
, on which a page-footing can be printed.
Record Clause
The RECORD
clause describes the size of the record.
Format :
[RECORD [ CONTAINS min-int-1 [TO max-int-1
]
CHARACTERS ]
Format 2:
[RECORD [ IS VARYING IN SIZE [FROM min-int-2][TO max-int-2]] CHARACTERS ]
[ DEPENDING ON record-depending ]
Syntax:
Min-int-1
is an integer.Max-int-1
is an integer.Min-int-2
is an integer.Max-int-2
is an integer.record-depending
is a data item described in the working-storage or linkage section.
General Rules:
- When used with
LINE SEQUENTIAL
files, theRECORD
clause is treated as commentary. - The Format 1
RECORD
clause can be used for fixed length records or variable length records. - If the Format 1
CONTAINS
phrase includes declarations ofmin-int
andmax-int
CHARACTERS
, andmax-int
is greater thanmin-int
, then the records have variable length. - If the Format 1
CONTAINS
phrase includes a single declaration ofmax-int CHARACTERS
, or declarations ofmin-int
andmax-int CHARACTERS
, wheremin-int
is equal tomax-int
, then the records have fixed length. - The Format 2
RECORD
clause is used for variable length records which may, optionally, rely on aDEPENDING ON
phrase - If a
DEPENDING ON
phrase is used, then the number of characters associated with the record length is derived from the value of the record depending variable. - In the absence of a
RECORD
clause, the compiler computes whether the records in a file are of fixed or variable length, what the length of the record is, and if they are of variable length, what the minimum and maximum record lengths are. - If the record size, as calculated by the compiler, is outside of the range described by the
RECORD
clause, the compiler will report an error, and the abort the compilation. In the example below, aRECORD CONTAINS 20 CHARACTERS
clause was entered in an FD with a record that contained 30 characters:
reswords.fd:5: Error: Record size too large 'reswords-record' (30)
Recording Mode Clause
The RECORDING MODE
clause is is recognized, and syntax is validated. RECORDING MODE F
and RECORDING MODE V
are supported. RECORDING MODE U
, S
, are treated as commentary.
General Format:
RECORDING MODE IS { F } ]
{ V }
{ U }
{ S }
General Rules:
LINE SEQUENTIAL
files declared withRECORDING MODE F
are stored with fixed record length. Trailing spaces are not removed.LINE SEQUENTIAL
files declared withRECORDING MODE V
are stored with variable record length.
Report Is Clause
The REPORT IS
clause is recognized, and syntax is validated. However, the REPORT IS
clause is otherwise treated as commentary.
General Format:
[ { REPORT IS } report-name ]
{ REPORTS ARE }
General Rules:
There are no General Rules.
Value Of Clause
The VALUE OF
clause is recognized, and syntax is validated. The handling of the VALUE OF
clause is affected by:
-fvalue-of-id-priority
or
value-of-id-priority:yes
With either of these conditions, the literal or data element that is the target of the VALUE OF FILE-ID
clause in the FD
overrides the target of the ASSIGN
clause for the file.
Otherwise, this setting is treated as commentary.
General Format:
[ VALUE OF { LABEL } IS value-of-name ]
{ FILE-ID }
Syntax:
Value-of-name
is a literal or data element. When associated with the VALUE OF FILE ID
phrase, it refers to the file's name, as it would appear in an ASSIGN TO
clause.
General Rules:
There are no General Rules.