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
SELECTstatement 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-namedescribed in a File Description (FD), may be referenced byOPEN,CLOSE,START,READ, andUNLOCKstatements- 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-1is an integerinteger-2is 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-SETclause may only be applied toSEQUENTIALfiles. Alphabet-nameis the name of an alphabet de scribed inSPECIAL-NAMES.- The
CODE-SETclause requires that all data items in the record description beUSAGE DISPLAY.
General Rules:
- The
CODE-SETclause usesalphabet-nameto represent the character set in which the file data is stored. - Usage of the
CODE-SETclause causes data conversion between the native character set and the character set described byalphabet-nameto occur on input and output FileI/Ooperations.
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 EXTERNALshares itsOPEN, andCLOSEstate,READ/WRITEbuffers, and file pointer state between separately compiled programs. - All programs using the file must have the same
SELECTandFDdeclarations for the file, and allFDdeclarations must contain theIS EXTERNALphrase. - A file description or data item may be declared
IS EXTERNALandIS GLOBALsimultaneously. GLOBAL Clause
The Global clause
General Format:
IS GLOBAL
General Rules:
- A file declared
IS GLOBALshares itsOPEN, andCLOSEstate,READ/WRITEbuffers, and file pointer state between a program and the nested programs it contains, and which together form a single compilation unit. - The
GLOBALclause 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
GLOBALclause may only be used with data items having an 01 data level. - The
GLOBALclause 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 EXTERNALandIS GLOBALsimultaneously.
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-linesis a numeric data item, or integer literal.footing-linenumber is a numeric data item, or integer literal.number-top-linesis a numeric data item or integer literal.number-bottom-linesis a numeric data item or integer literal.
General Rules:
page-linesis maintained as an internal counter. When counter reachespage-lines, theend-of-pagecondition is trigge red, and can be trapped by theWRITEstatement.- The
LINES AT TOP number-top-linesclause is the number of line feeds that are written after advancing a page. - The
LINES AT BOTTOM number-bottom-linesclause is the number of line feeds that are written before advancing a page. - The
FOOTING ATfooting ine number describes an area of the report above theLINESatBOTTOM, 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-1is an integer.Max-int-1is an integer.Min-int-2is an integer.Max-int-2is an integer.record-dependingis a data item described in the working-storage or linkage section.
General Rules:
- When used with
LINE SEQUENTIALfiles, theRECORDclause is treated as commentary. - The Format 1
RECORDclause can be used for fixed length records or variable length records. - If the Format 1
CONTAINSphrase includes declarations ofmin-intandmax-intCHARACTERS, andmax-intis greater thanmin-int, then the records have variable length. - If the Format 1
CONTAINSphrase includes a single declaration ofmax-int CHARACTERS, or declarations ofmin-intandmax-int CHARACTERS, wheremin-intis equal tomax-int, then the records have fixed length. - The Format 2
RECORDclause is used for variable length records which may, optionally, rely on aDEPENDING ONphrase - If a
DEPENDING ONphrase 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
RECORDclause, 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
RECORDclause, the compiler will report an error, and the abort the compilation. In the example below, aRECORD CONTAINS 20 CHARACTERSclause 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 SEQUENTIALfiles declared withRECORDING MODE Fare stored with fixed record length. Trailing spaces are not removed.LINE SEQUENTIALfiles declared withRECORDING MODE Vare 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.