HP 3000 Manuals

Data Division [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation


COBOL/HP-UX Language Reference for the Series 700 and 800

Data Division 
________________________________________________________________________
|The Data Division header is optional .  (MF)                          |
________________________________________________________________________

            

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.
________________________________________________________________________
|(ANS85)                                                               |
|Provided no reference is made to a given data-name or record-name, it |
|need not be unique by qualification.                                  |
________________________________________________________________________

            

General Format 

     WORKING-STORAGE SECTION.

           [ record-description-entry   ]
           [ 77-level-description-entry ] ...

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 non-contiguous 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

   *   The PICTURE clause, the USAGE IS INDEX clause

       or the USAGE IS POINTER clause (VSC2) (MF)

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 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 (ANS85) 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 COBOL Concepts and in the section "The Data
Description - Complete Entry Skeleton"  in this chapter.

Initial Values 

The initial value of any item in the Working-Storage Section except an
index data item 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.
________________________________________________________________________
|The Local-Storage Section                                             |
|                                                                      |
|(MF)                                                                  |
|                                                                      |
|Function                                                              |
|                                                                      |
|A separate copy of the Local-Storage Section is 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 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.                                                     |
|                                                                      |
|General Format                                                        |
|                                                                      |
|     LOCAL-STORAGE SECTION .                                          |
|                                                                      |
|           [ record-description         ]                             |
|           [ 77-level-description-entry ]                             |
|                                                                      |
|Syntax Rules                                                          |
|                                                                      |
|                                                                      |
|   1.  The Local-Storage Section must appear between the              |
|       Working-Storage Section and the Linkage Section.               |
|                                                                      |
|   2.  EXTERNAL data is not allowed.                                  |
|                                                                      |
|   3.  GLOBAL data 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.                                                      |
________________________________________________________________________

            
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|General Rules                                                         |
|                                                                      |
|                                                                      |
|   1.  The DEFAULT-BYTE system 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 
________________________________________________________________________
|(OSVS) (VSC2) (MF)                                                    |
|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) (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.
________________________________________________________________________
|(MF)                                                                  |
|(Note that such data also can 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.
________________________________________________________________________
|(VSC2) (MF)                                                           |
|An ADDRESS special register is maintained for each record (that is,   |
|01 or 77 level 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.                                                             |
________________________________________________________________________

            
________________________________________________________________________
|(MF)                                                                  |
|The ADDRESS OF phrase 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 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:

   *   Level-number 77

   *   Data-name

   *   The PICTURE clause or the USAGE IS INDEX clause

        or the USAGE IS POINTER clause (MF) (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).
________________________________________________________________________
|(OSVS) (VSC2) (MF)                                                    |
|The VALUE clause is allowed, and is treated as documentary.           |
________________________________________________________________________

            

The Data Description - Complete Entry Skeleton 

Function 

A data description entry specifies the characteristics of a particular
item of data.
________________________________________________________________________
|(ANS85)                                                               |
|Within the Inter-Program Communication module, 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.                                          |
|                                                                      |
|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 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 if either is specified; otherwise it must immediately follow the level number. (ANS85) 3. The PICTURE clause must be specified for every elementary item except an index data item, a pointer or an internal floating-point data item, (VSC2) (MF) in which case use of this clause is prohibited. 4. The words THRU and THROUGH are equivalent. ________________________________________________________________________ |(ANS85) | | | | | | | |5. The EXTERNAL clause can be specified only in data description | | entries in the Working-Storage Section whose level-number is | | 01. | | | |6. The EXTERNAL clause and the REDEFINES clause must not be | | specified in the same data description entry. | | | |7. The GLOBAL clause can be specified only in data description | | entries whose level-number is 01. | | | |8. 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. | | | ________________________________________________________________________ General Rules 1. The clauses SYNCHRONIZED, PICTURE, JUSTIFIED, and BLANK WHEN ZERO, must not be specified except for an elementary data item. ________________________________________________________________________ |(OSVS) (VSC2) | |The SYNCHRONIZED clause can be specified for a group item. | ________________________________________________________________________ 2. Format 3 is used for each condition-name. Each condition-name requires a separate entry with level-number 88. Format 3 contains the name of the condition and the value, values, or range of values associated with the condition-name. The condition-name entries for a particular conditional variable must immediately follow the entry describing the item with which the condition-name is associated. A condition-name can be associated with any data description entry which contains a level-number except the following: a. Another condition-name. b. A level 66 item. c. A group containing items with descriptions including JUSTIFIED, SYNCHRONIZED or USAGE (other than USAGE IS DISPLAY). d. An indexor pointer (VSC2) (MF) data item (see the section The USAGE IS INDEX Clause in this chapter). ________________________________________________________________________ |e. A constant-name. (MF) | ________________________________________________________________________ ________________________________________________________________________ |(MF) (VSC2) | | | | | | | |3. Condition-names can be associated with internal floating-point | | items. | | | ________________________________________________________________________ ________________________________________________________________________ |(MF) | |Condition-names can be associated with external floating-point | |items. | ________________________________________________________________________ ________________________________________________________________________ |(MF) | | | | | | | |4. Format 4 defines a constant-name, which is a symbolic name | | representing a constant value assigned to it when the source code| | is passed through your COBOL system. Your COBOL system replaces | | each reference to a constant-name by its value. | | | ________________________________________________________________________ ________________________________________________________________________ |(OSVS) (VSC2) | | | | | | | |5. Data-item-2 and data-item-3 can be implicitly qualified. | | | ________________________________________________________________________ ________________________________________________________________________ |(ANS85) | | | |File Connector | | | |A file connector is a storage area which contains information about | |a file and is used as the linkage between a file-name and a | |physical file and between a file-name and its associated record | |area. | | | |Global Names and Local Names | | | |A data-name names a data item. A file-name names a file connector. | |These names are classified as either global or local. | | | |A global name can be used to refer to the object with which it is | |associated either from within the program in which the global name is | |declared, or from within any other program which is contained in the | |program which declares the global name. | ________________________________________________________________________ ________________________________________________________________________ |(ANS85) | |A local name, however, can be used only to refer to the object with | |which it is associated from within the program in which the local name| |is declared. Some names are always global; other names are | |always local; and some other names are either local or global | |depending upon specifications in the program in which the names are | |declared. | | | |A record-name is global if the GLOBAL clause is specified in the | |record description entry by which the record-name is declared or, in | |the case of record description entries in the File Section, if the | |GLOBAL clause is specified in the file description entry for the | |file-name associated with the record description entry. | | | |A data-name is global if the GLOBAL clause is specified either in | |the data description entry by which the data-name is declared | |or in another entry to which that data description entry is | |subordinate. | | | |A condition-name declared in a data description entry is global if | |that entry is subordinate to another entry in which the GLOBAL | |clause is specified. However, specific rules sometimes prohibit | |specification of the GLOBAL clause for certain data description, file | |description, or record description entries. A file-name is global if | |the GLOBAL clause is specified in the file description entry for that | |file-name. | | | |A file-name is global if the GLOBAL clause is specified in the file | |description entry for that file-name. | | | |If a data-name, a file-name, or a condition-name declared in a data | |description entry is not global, the name is local. | | | |Global names are transitive across programs contained within other | |programs. | | | |External Objects and Internal Objects | | | |Accessible data items usually require that certain representations of | |data be stored. File connectors usually require that certain | |information concerning files be stored. The storage associated with a| |data item or a file connector can be external or internal to the | |program in which the object is declared. | | | |A data item or file connector is external if the storage associated | |with that object is associated with the run unit rather than with any | |particular program within the run unit. An external object can be | |referenced by any program in the run unit which describes the object. | |References to an external object from different programs using | |separate descriptions of the objects are always to the same object. | |In a run unit, there is only one representation of an external | |object. | ________________________________________________________________________ ________________________________________________________________________ |(ANS85) | |An object is internal if the storage associated with that object is | |associated only with the program which describes the object. | | | |External and internal objects can have either global or local | |names. | | | |A data record described in the Working-Storage Section is given the | |external attribute by the presence of the EXTERNAL clause in its data | |description entry. Any data item described by a data description | |entry subordinate to an entry describing an external record also | |attains the external attribute. If a record or data item does not | |have the external attribute, it is part of the internal data of the | |program in which it is described. | | | |A file connector is given the external attribute by the presence of | |the EXTERNAL clause in the associated file description entry. If | |the file connector does not have the external attribute, it is | |internal to the program in which the associated file-name is | |described. | | | |The data record described subordinate to a file description entry | |which does not contain the EXTERNAL clause or a sort-merge file | |description entry, and any data items described subordinate to the | |data description entries for such records, are always internal to the | |program describing the file-name. If the EXTERNAL clause is included | |in the file description entry, the data records and the data items | |attain the external attribute. | | | |Data records, subordinate data items, and various associated control | |information described in the Linkage, Communication, and Report | |Sections of a program are always considered to be internal to the | |program describing that data. Special considerations apply to data | |described in the Linkage Section whereby an association is made | |between the data records described and other data items accessible to | |other programs. | ________________________________________________________________________ The BLANK WHEN ZERO Clause Function The BLANK WHEN ZERO clause permits the blanking of an item when its value is zero. General Format
[]
Syntax Rules 1. The BLANK WHEN ZERO clause can be used only for an elementary item whose PICTURE is specified as numeric (with implicit or explicit USAGE IS DISPLAY) or numeric edited. (See the section "The PICTURE Clause" later in this chapter.) 2. The asterisk when used as the zero suppression symbol and the clause BLANK WHEN ZERO should not appear in the same entry. ________________________________________________________________________ |(OSVS) | |This construct is, however, permitted in which case, zero suppression | |overrides the BLANK WHEN ZERO clause. | ________________________________________________________________________ General Rules 1. When the BLANK WHEN ZERO clause is used, the item will contain nothing but spaces if the value of the item is zero. 2. When the BLANK WHEN ZERO clause is used for an item whose PICTURE is numeric, the category of the item is considered to be numeric edited. The Data-Name or FILLER Clause Function A data-name specifies the name of the data being described. The word FILLER can be used to specify an elementary item of the logical record that cannot be referred to explicitly. General Format
[]
Syntax Rule In the File, Working-Storage, Communication and Linkage Sections, a data-name or the key word FILLER, if either is specified, (ANS85) must be the first word following the level-number in each data description entry. General Rules 1. The key word FILLER can be used to name an elementary item or group in a record. Under no circumstances can a FILLER item be referred to explicitly. However, the key word FILLER can be used as a conditional variable because such use does not require explicit reference to the FILLER item but only to the value contained therein. ________________________________________________________________________ |(ANS85) | | | | | | | |2. If this clause is omitted, the data item being described is | | treated as though FILLER had been specified. | | | ________________________________________________________________________ ________________________________________________________________________ |The EXTERNAL Clause | | | |(ANS85) | | | |Function | | | |The EXTERNAL clause specifies that a data item or a file connector is | |external. The constituent data items and group items of an external | |data record are available to every program in the run unit which | |describes that record. | | | |General Format | | | | IS EXTERNAL | | | |Syntax Rules | | | | | | 1. The EXTERNAL clause can be specified only in file description | | entries, or in record description entries in the | | Working-Storage Section. | | | | 2. In the same program, the data-name specified as the subject of | | the entry whose level-number is 01 that includes the EXTERNAL | | clause must not be the same data-name specified for any | | other data description entry which includes the EXTERNAL | | clause. | | | | 3. The VALUE clause must not be used in any data description entry| | that includes, or is subordinate to an entry that includes, the| | EXTERNAL clause. The VALUE clause can be specified for | | condition-name entries associated with such data description | | entries. | | | |General Rules | | | | | | 1. The data contained in the record named by the data-name clause | | is external and can be accessed and processed by any program in| | the run unit which describes and, optionally, redefines it | | subject to the following general rules. | | | | 2. Within a run unit, if two or more programs describe the same | | external data record, each record-name of the associated record| | description entries must be the same and the records must | | define the same number of standard data format characters. | | However, a program which describes an external record can | | contain a data description entry including the REDEFINES clause| | which redefines the complete external record, and this complete| | redefinition need not occur identically in other programs in | | the run unit. See the section "The REDEFINES Clause" | | . | | | | 3. Use of the EXTERNAL clause does not imply that the associated | | file-name or data-name is a global name. See the section "The | | GLOBAL Clause" later in this chapter. | | | | 4. The file connector associated with this description entry is an| | external file connecter. | | | | See your COBOL System Reference for further information on | | files with the EXTERNAL attribute. (MF) | ________________________________________________________________________ The GLOBAL Clause ________________________________________________________________________ |(ANS85) | | | |Function | | | |The GLOBAL clause specifies that a data-name, a file-name, or | |a report-name is a global name. A global name is available | |to every program contained within the program which declares | |it. | | | |General Format | | | | IS GLOBAL | | | |Syntax Rules | | | | | | 1. The GLOBAL clause can be specified only in data description | | entries whose level-number is 01 in the File Section or the | | Working-Storage Section, file description entries, or report | | description entries. | | | | The GLOBAL clause can also be specified in the Linkage Section.| | (MF) | | | | 2. In the same Data Division, the data description entries for any| | two data items for which the same data-name is specified must | | not include the GLOBAL clause. | | | | 3. If the SAME RECORD AREA clause is specified for several files, | | the record description entries or the file description entries | | for these files must not include the GLOBAL clause. | | | |General Rules | | | | | | 1. A data-name, file-name or report-name described using a GLOBAL | | clause is a global name. All data-names subordinate to a | | global name are global names. All condition-names associated | | with a global name are global names. | | | | 2. A statement in a program contained directly or indirectly | | within a program which describes a global name can reference | | that name without describing it again. See the section Scope | | of Names in Chapter 2 , COBOL Concepts. | | | | 3. If the GLOBAL clause is used in a data description entry which | | contains the REDEFINES clause, it is only the subject of that | | REDEFINES clause which possesses the global attribute. | ________________________________________________________________________ The JUSTIFIED Clause Function The JUSTIFIED clause specifies non-standard positioning of data within a receiving data item. General Format
[]
Syntax Rules 1. The JUSTIFIED clause can be specified only at the elementary item level. 2. JUST is an abbreviation for JUSTIFIED. 3. The JUSTIFIED clause cannot be specified for any data item described as numeric or for which editing is specified. 4. The JUSTIFIED clause cannot be specified for an index data item (see the section The USAGE IS INDEX Clause) ,or for a pointer data item. (VSC2) (MF) ________________________________________________________________________ |(MF) (VSC2) (OSVS) | | | | | | | |5. The JUSTIFIED clause cannot be specified for external or internal| | floating-point data items. | | | ________________________________________________________________________ General Rules 1. When a receiving data item is described with the JUSTIFIED clause and the sending data item is larger than the receiving data item, the leftmost characters are truncated. When the receiving data item is described with the JUSTIFIED clause and it is larger than the sending data item, the data is aligned at the rightmost character position in the data item with space fill for the leftmost character positions. Note that the contents of the sending data item are not taken into account, that is, trailing spaces within the sending data item are not suppressed. For example, if a data item PIC X(4) whose value is A____ (that is, A followed by three spaces) is moved into a data item PIC X(6) JUSTIFIED the result will be ___A____. If the same data item is moved to one with PIC X(3) JUSTIFIED the result will be ____ that is, the leftmost character is truncated. 2. When the JUSTIFIED clause is omitted, the standard rules for aligning data within an elementary item apply. (See the section "Standard Alignment Rules" in the chapter COBOL Concepts.) Level Number Function The level-number shows the hierarchy of data within a logical record. In addition, it is used to identify entries for working storage items, linkage items, condition-names,constant-names (MF) and the RENAMES clause. General Format level-number Syntax Rules 1. A level-number is required as the first element in each data description entry. 2. Data description entries subordinate to an FD, CD, or SD entry must have level-numbers with the values 01 through 49, 66,78 (MF) or 88. (See "The File Description - The Complete Entry Skeleton" in the chapter File Input and Output.) 3. Data description entries in the Report Section and Screen Section must have level-numbers with the values 01 through 49 , or 78. (MF) 4. Data description entries in the Working-Storage Section , LOCAL-STORAGE (MF) and Linkage Section must have level-numbers with the values 01 through 49, 66, 77 , 78 (MF) or 88. 5. A level-number can be a one or two digit number. General Rules 1. The level-number 01 identifies the first entry in each record description. 2. Special level numbers have been assigned to certain entries where there is no real concept of level hierarchy: a. The level-number 77 is assigned to identify noncontiguous working storage data items, noncontiguous linkage data items, and can be used only as described by Format 1 of the data description skeleton earlier in this chapter. b. Level number 66 is assigned to identify RENAMES entries and can be used only as described in Format 2 of the data description skeleton earlier in this chapter. c. Level number 88 is assigned to entries which define condition-names associated with a conditional variable and can be used only as described in Format 3 of the data description skeleton earlier in this chapter. ________________________________________________________________________ |(MF) | | | | | | | |d. Level number 78 is assigned to entries which define | | constant-names. It can be used only as described in Format 4 of | | the data description skeleton earlier in this chapter. | | | ________________________________________________________________________ 3. Multiple level 01 entries subordinate to a CD, FD or SD entry represent implicit redefinitions of the same area.


MPE/iX 5.0 Documentation