PreviousEnvironment Division Data Division - Data DescriptionNext"

Chapter 7: Data Division

7.1 Data Division

The Data Division header is optional .

7.1.1 General Description

The Data Division describes the data that the runtime module is to accept as input, to manipulate, to create, or to produce as output.

7.1.1.1 Structure

The following is the General Format of the sections in the Data Division, and defines the order of presentation in the source element.

General Format

7.1.2 File Section

The file description entry (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 clauses specify 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.

7.1.2.1 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 SORT and MERGE statements 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.

The files specified in the USING and GIVING phrases of the SORT and MERGE statements can be described explicitly in the FILE-CONTROL paragraph as having either indexed or relative organization and can have either sequential or dynamic access mode.

7.1.2.2 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 record description 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 - The Complete Entry Skeleton later in this chapter.

7.1.2.3 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.

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.

7.1.3 General Description

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 file-name-1 may appear in any order.

  2. 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,
dialm.gifLine Sequential,
Relative and Indexed Files)
  1. The level indicator FD identifies the beginning of a file description and must precede the file-name.

  2. One or more record description entries must follow the file description entry.
Format 4 (Sort-Merge Files)
  1. The level indicator SD identifies the beginning of the sort-merge file description and must precede the file-name.

  2. The clauses which follow the name of the file are optional and may appear in any order.

  3. 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 Rules

Format 1 (Record Sequential Files)
  1. If the file description entry for a sequential file contains the LINAGE clause and the EXTERNAL clause, the LINAGE-COUNTER data 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.

7.1.4 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.

Provided no reference is made to a given data-name or record-name, it need not be unique by qualification.

General Format

7.1.4.1 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:

Other data description clauses are optional and can be used to complete the description of the item if necessary.

7.1.4.2 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.

7.1.4.3 Record Description Structure

A rec ord 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

optionally

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.

7.1.4.4 Initial Values

The initial value of any item in the Working-Storage Section except an index data item

or a type definition

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.

7.1.5 Local-Storage Section

Function

A separate copy of the Local-Storage Section is created each time the runtime element is activated and exists only during the lifetime of that activation. The Local-Storage Section is provided specifically for use in methods and 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.

Provided no reference is made to a given data-name or record-name, it need not be unique by qualification.

General Format

Syntax Rules

  1. The EXTERNAL clause is not allowed.

  2. The GLOBAL clause is not allowed.

  3. The syntax CALL ... USING local-data-item is permitted.

  4. The syntax ENTRY ... USING local-data-item is not permitted.

  5. The syntax PROCEDURE DIVISION ... USING local-data-item is not permitted.

  6. The LOCAL-STORAGE SECTION header is not permitted in nested programs.

  7. 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.

General Rules

  1. The DEFAULT-BYTE Compiler directive 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 Compiler directive set .

  3. The VALUE clause is treated as documentary.

7.1.6 Linkage Section

All references to PROCEDURE DIVISION USING in the following discussion also apply to ENTRY USING.

Except as described under the section The SET Statement,

the Linkage Section in a program definition 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 always meaningful in a method.

Formal parameters and returning items described in the linkage section of a source element are referred to both by that source element, when it is activated, and by the activating source element.

Such data can also be described in the File and Working-Storage Sections .

No storage is allocated for data items defined in the Linkage Section. Procedure Division references to these data items are resolved at run time by equating the reference in the activated runtime element to the location used in the activating runtime element. In the case of index-names, no such correspondence is established. Index-names in the activated and activating runtime element always refer to separate indices.

Data items defined in the Linkage Section of a program can be referenced within the Procedure Division of that 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 source element if it is referenced in the Procedure Division. 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 that redefine or rename these items, data items subordinate to any of these data-names, and condition-names and/or index- names associated with any such data-names and/or subordinate data items can be referenced in the Procedure Division.

The description of the parameters and the returning items that appear in a linkage section must follow the rules specified in Conformance for parameters and returning items.

7.1.6.1 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 noncontiguous elementary 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:

Other data description clauses are optional and can be used to complete the description of the item if necessary.

7.1.6.2 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.

7.1.6.3 Initial Values

The VALUE clause must not be specified in the Linkage Section except in condition-name entries (level 88).

The VALUE clause is allowed, and is treated as documentary.


Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousEnvironment Division Data Division - Data DescriptionNext"