HP 3000 Manuals

File Section [ Micro Focus COBOL Language Reference ] MPE/iX 5.0 Documentation


Micro Focus COBOL Language Reference

File Section 

In a COBOL program the file descriptionentry (FD) represents the highest
level of organization in the File Section.  The FILE SECTION header is
followed by a file description entry consisting of a level indicator
(FD), a file-name and a series of independent clauses.  The FD
clausesspecify the size of the logical and physical records, the external
name of the file, and the names of the data records which comprise the
file.  The entry itself is terminated by a period.

An SD file description gives information about the size and the names of
the data records associated with the file to be sorted or merged.  There
are no label procedures which the user can control, and the rules for
blocking and internal storage are peculiar to the SORT and MERGE
statements.

Relationship with Sort-merge 

The sort-merge module provides the capability to sort elements of a table
in the Data Division.  The files specified in the USING and GIVING
phrases of the SORTand MERGEstatements must be described implicitly or
explicitly in the FILE-CONTROL paragraph as having sequential
organization and sequential access mode.  No input-output statement can
be executed for the file named in the sort-merge file description.

For ANS85 only:  The files specified in the USINGand GIVINGphrases of the
SORT and MERGE statements can be described explicitly in the
FILE-CONTROLparagraph as having either indexed or relative organization
and can have either sequential or dynamic access mode.

Record Description Structure 

A record description consists of a set of data description entries which
describe the characteristics of a particular record.  Each data
description entry consists of a level-number, a data-name if required and
a series of independent clauses as required.  A recorddescription has a
hierarchical structure and, therefore, the clauses used with an entry can
vary considerably, depending upon whether or not it is followed by
subordinate entries.  The structure of a record description is defined in
the section Concept Of Levels in the chapter Concepts of the COBOL 
Language, while the elements allowed in a record description are shown in
the section Data Description - Complete Entry Skeleton later in this
chapter.

The File Description - The Complete Entry Skeleton 

Function.   

The file description comprises information concerning the physical
structure, identification, and record-names pertaining to a given file.

For ANS85 only:  It determines the internal or external attributes of a
file connector, of the associated data records, and of the associated
data items.  The file description entry also determines whether a
file-name is a local name or a global name .

General Formats.   

Format 1 (Record Sequential Files).   

[]
Format 2 (Line Sequential Files).
[]
Format 3 (Relative and Indexed Files).
[]
[]
Format 4 (Sort-Merge Files).
[]
Syntax Rules All Formats (All Files). 1. The clauses which follow the name of the file are optional in many cases, and their order of appearance is immaterial. For ANS85 only: All clauses are optional . 2. For MF only: If the VALUE OF FILE-ID clause is specified, literal-1 must be a nonnumeric literal and cannot be a figurative constant. Formats 1, 2 and 3 (Record Sequential, Line Sequential, Relative. and Indexed Files) 3. The level indicator FD identifies the beginning of a file description and must precede the file-name. 4. One or more record description entries must follow the file description entry. Format 4 (Sort-Merge Files). 5. The level indicator SD identifies the beginning of the sort-merge file description and must precede the file-name. 6. The clauses which follow the name of the file are optional and their order of appearance is immaterial. 7. One or more record description entries must follow the sort-merge file description entry. However, no input-output statements can be executed for this file. General Rule. Format 1 (Record Sequential Files). If the file description entry for a sequential file contains the LINAGEclause and the EXTERNAL clause, the LINAGE-COUNTERdata item is an external data item. If the file description entry for a sequential file contains the LINAGE clause and the GLOBAL clause, the special register LINAGE-COUNTER is a global name. Working-Storage Section The Working-Storage Section is composed of the section header, followed by data description entries for noncontiguous data items and/or record description entries. Each Working-Storage Section record-name and noncontiguous item-name should be unique since it cannot be qualified. Subordinate data-names need not be unique if they can be made unique by qualification. For ANS85 only: Provided no reference is made to a given data-name or record-name, it need not be unique by qualification. General Format.
[]
Noncontiguous Working-Storage (77-level-description-entry). Items and constants in the Working-Storage Section which bear no hierarchical relationship to one another need not be grouped into records, provided they do not need to be further subdivided. Instead, they are classified as noncontiguous elementary items and are defined in a separate data description entry which begins with the special level-number, 77. The following data clauses are required in each data description entry: * Level-number 77 * Data-name * Either * The PICTURE clause or * the USAGE clause specifying USAGE INDEX, USAGE COMPUTATIONAL-1, USAGE COMPUTATIONAL-2, USAGE POINTER, or USAGE PROCEDURE-POINTER.(MF and VSC2) Other data description clauses are optional and can be used to complete the description of the item if necessary. Working-Storage Records (record-description-entry). Data elements in the Working-Storage Section which bear a definite hierarchical relationship to one another must be grouped into records according to the rules for formation of record descriptions. All clauses which are used in record descriptions in the File Section can be used in record descriptions in the Working-Storage Section. Record Description Structure. A record descriptionconsists of a set of data description entries which describe the characteristics of a particular record. Each data description entry consists of a level-number optionally (ANS85 only) followed by the data-name or FILLER clause, followed by a series of independent clauses as required. A record description can have a hierarchical structure and therefore the clauses used within an entry can vary considerably, depending upon whether or not it is followed by subordinate entries. The structure of a record description and the elements allowed in a record description entry are explained in the section Concept Of Levels in the chapter Concepts of the COBOL Language and in the section The Data Description - Complete Entry Skeleton later in this chapter. Initial Values. The initial value of any item in the Working-Storage Section except an index data item or a type defintion(MF) can be specified by using the VALUE clause with the data item. The initial value of any index data item or any data item not associated with a VALUE clause is undefined. See the section Initial State of a Program earlier in this chapter. For MF only: Local-Storage Section Function. A separate copy of the Local-Storage Sectionis created each time the program is called and exists only during the lifetime of that CALL. The Local-Storage Section is provided specifically for use in recursive calls. The Local-Storage Section is composed of the section header, followed by data description entries for noncontiguous data items and/or record description entries. Each Local-Storage Section record-name and noncontiguous item-name should be unique since it cannot be qualified. Subordinate data-names need not be unique if they can be made unique by qualification. General Format.
[]
Syntax Rules. 1. The Local-Storage Section must appear between the Working-Storage Section and the Linkage Section. 2. EXTERNAL datais not allowed. 3. GLOBALdata is not allowed. 4. The VALUE clause is allowed, and is treated as documentary. 5. The syntax CALL...USING local-data-item is permitted. 6. The syntax ENTRY...USING local-data-item is not permitted. 7. The syntax PROCEDURE DIVISION...USING local-data-item is not permitted. 8. The LOCAL-STORAGE SECTION header is not permitted in nested programs. General Rules. 1. The DEFAULT-BYTEsystem directive, described in your COBOL System Reference does not apply to items declared within the Local-Storage Section. 2. Programs which contain a Local-Storage Section must be submitted to the COBOL system with the MF directive set (see your COBOL System Reference for details). 3. The COBOL system allows recursion in programs if and only if a Local-Storage Section appears in the program. It need not have any records, but the section header must be present for recursion to be accepted at run time. Linkage Section For OSVS, VSC2, and MF only: All references to PROCEDURE DIVISION USING in the following discussion also apply to ENTRY USING . Except as described under the section The SET Statement ,(VSC2 and MF) the Linkage Section in a program is meaningful if, and only if, the object program is to function under the control of a CALL statement, and the CALL statement in the calling program contains a USING phrase. The Linkage Section is used in the invoked program for describing data that is available through the invoking program but is to be referred to in both the invoking and the invoked program. For MF only: Such data can also be described in the File and Working-Storage Sections of the program. No space is allocated in the program for data items referenced by data-names in the Linkage Section of that program. Procedure Division references to these data items are resolved at run time by equating the reference in the invoked program to the location used in the invoking program. In the case of index-names, no such correspondence is established. Index-names in the invoked and invoking program always refer to separate indices. Data items defined in the Linkage Section of the invoked program can be referenced within the Procedure Division of the invoked program only if they are specified as operands of the USING phrase of the PROCEDURE DIVISION header or are subordinate to such operands, and the object program is under the control of a CALL statement which specifies a USING phrase. The structure of the Linkage Section is the same as that previously described for the Working-Storage Section, beginning with a section header, followed by data description entries for noncontiguous data items and/or record description entries. Each Linkage Section record-name and noncontiguous item-name must be unique within the invoked program since it cannot be qualified if they are referenced in the Procedure Division (ANS85). .Of those items defined in the Linkage Section only data-name-1, data-name-2,...in the USING phrase of the PROCEDURE DIVISION header, data items subordinate to these data-names, and condition-names and/or index- names associated with such data-names and/or subordinate data items can be referenced in the Procedure Division. For VSC2 and MF only: An ADDRESS special registeris maintained for each record (that is, 01or 77level item) in the Linkage Section. These special registers can be referred to in the USING phrase, allowing the address of a record rather than its contents to be passed or received. For MF only: The ADDRESS OFphrase can refer to any data item defined in a program's Data Division. Noncontiguous Linkage Storage. Items in the Linkage Section that bear no hierarchic relationship to one another need not be grouped into records and are classified and defined as noncontiguouselementary items. Each of these data items is defined in a separate data description entry which begins with the special level-number 77. The following data clauses are required in each data description entry: * Level-number 77 * Data-name * Either * The PICTURE clause or * the USAGE clause specifying USAGE INDEX, USAGE COMPUTATIONAL-1, USAGE COMPUTATIONAL-2, USAGE POINTER, OR USAGE PROCEDURE-POINTER.(MF and VSC2) Other data description clauses are optional and can be used to complete the description of the item if necessary. Linkage Records. Data elements in the Linkage Section which bear a definite hierarchic relationship to one another must be grouped into records according to the rules for formation of record descriptions. Any clause which is used in an input or output record description can be used in a Linkage Section. Initial Values. The VALUE clause must not be specified in the Linkage Section except in condition-name entries (level 88). For OSVS, VSC2 and MF only: The VALUE clause is allowed, and is treated as documentary . Data Description Complete Entry Skeleton. Function. A data description entry specifies the characteristics of a particular item of data or the characteristics of a programmer-defined type of data which can then be used to specify the description of one or more particular items of data.(MF) For ANS85 only: A level 01 data description entry within the Working-Storage Section or File Section determines whether the data record and its subordinate data items have local names or global names. For ANS85 only: A level 01 data description in the Working-Storage Section determines the internal or external attribute of the data record and its subordinate data items. General Formats. Format 1.
[]
[]
Format 2.
[]
Format 3.
[]
For MF only: Format 4.
[]
Syntax Rules. 1. The level-number in Format 1 can be any number from 01 through 49 or 77. 2. The clauses can be written in any order with two exceptions: the data-name-1 or FILLER clause , if specified (ANS85), must immediately follow the level-number; the REDEFINES clause, when used, must immediately follow the data-name-1 clause or FILLER clause if either is specified; otherwise it must immediately follow the level number. (ANS85) . 3. The PICTUREclause must be specified for every elementary item except an index data item, a pointer or an internal floating-point data item,(MF, VSC2) in which case use of this clause is prohibited. 4. The words THRU and THROUGH are equivalent. 5. For ANS85 only: The EXTERNAL clause can be specified only in data description entries in the Working-Storage Section whose level-number is 01. 6. For ANS85 only: The EXTERNAL clause and the REDEFINES clause must not be specified in the same data description entry. 7. For ANS85 only: The GLOBAL clause can be specified only in data description entries whose level-number is 01. 8. For ANS85 only: Data-name-1 must be specified for any entry containing the GLOBAL or EXTERNAL clause, or for record descriptions associated with a file description entry which contains the EXTERNAL or GLOBAL clause. 9. For MF only: The TYPEDEF clause can only be specified in data description entries whose level-number is 01. 10. For MF only: The TYPEDEF clause can only be used when data-name-1 is also specified. In other words, it cannot be used in the same data descrition with either an explicit or implicit FILLER clause. Note that if the TYPEDEF clause is specified for a group item, subordinate data descriptions can be defined with either an implicit or explicit FILLER clause. 11. The clauses SYNCHRONIZED, PICTURE, JUSTIFIED, and BLANK WHEN ZERO must not be specified except for an elementary data item. For VSC2 and OSVS only: The SYNCHRONIZED clause can be specified for a group item. 12. For MF only: Literal-5 and integer-1 must not be floating-point values and must not be negative values. 13. If literal-5 is used as part of an expression, it must be a positive or zero integer. 14. For VSC2 and OSVS only: Data-name-2 and data-name-3 can be implicitly qualified.


MPE/iX 5.0 Documentation