HP 3000 Manuals

Data Description Entries [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

Data Description Entries 

A data description entry is composed of a level number followed by a data
name, and then followed by a set of data clauses.

The level numbers can be 01 to 49 for record description entries, 77 for
unrelated data items, 66 for alternative groupings of elementary items in
the preceding record description entry, and 88 for condition names.

A level number is required for each data description entry, and must be
the first element of such an entry.

The level numbers 01 and 77 must begin in Area A. Other level numbers may
begin in either Area A or Area B.

All data description entries are discussed in the following pages,
beginning with level 77 entries.

77 Level Description Entries 

Noncontiguous data items are data items or constants that are not
subdivided and bear no hierarchical relationship to one another.  That
is, noncontiguous data items are unrelated data items. 

These data items are only defined in the WORKING-STORAGE and LINKAGE
SECTIONs, and have level numbers of 77.  Recall, however, that those
items defined in the LINKAGE SECTION do not have any storage allocated
for them.

Each name used for a noncontiguous data item must be unique since it
cannot be qualified.  For example,

     WORKING-STORAGE SECTION.

           77 COUNTER                  PICTURE 9(4) VALUE 0.
           77 MID-TOTALS               PICTURE 9(6)V99 VALUE O.

COUNTER is an accumulator, and MID-TOTALS is an intermediate storage
variable.  Because they are not subdivided, and they have no immediate
relationship to any other data items, they are described using level 77
entries.

Record Description Entries 

At least one record description entry must follow each FD or SD file
description entry.  This discussion of record description entries is
applicable to either type of file description, as well as for the LINKAGE
and WORKING-STORAGE SECTIONS.

A record description consists of one or more data description entries.

Associated with each data description entry is a level number chosen from
the set 01 to 49, 66, or 88.  The level number for the first data
description entry of any record description must be 01 (or simply 1).
Succeeding level numbers of data description entries for the same record
description may range from 01 to 49, or may be 66.  If, however, multiple
01 entries are used for a given level indicator (FD, or SD) they
represent implicit redefinitions of the same area.  The 02 to 49 level
numbers are used to specify subsets of the characters of a record.

The level number 66 is used only when the data description uses the
RENAMES clause to regroup data items.  Refer to the description of the
RENAMES clause later in this chapter.

The level number 88 is used only for a condition name data description.
It is always associated with a VALUE clause.  Refer to "Condition Names"
later in this chapter.) 

Data names subordinate to record names can be nonunique, provided they
can be made unique by qualification.

The three general formats for data description entries are shown below
and described in the following paragraphs.

[]
[]
In the first format, the level number may be any number from 01 to 49, or 77. It cannot be 66 or 88. If it is used, the data name or FILLER clause must immediately follow the level number, and the REDEFINES clause (if used) must immediately follow the data-name-1 clause. Except for these two conditions, all other clauses, if used, may be written in any order. The PICTURE clause must be used for every elementary item except an index data item. A PICTURE clause must not be used for an index data item. Data elements and constants bearing a definite hierarchic relationship to one another must be grouped into records. The initial value of any data item except an index data item is specified by using the VALUE clause in the description of that item. Because the VALUE clause does not apply to index data items, the initial value of any such item is unknown. You may not use the SYNCHRONIZED, PICTURE, JUSTIFIED, or BLANK WHEN ZERO clauses for any but elementary data items. Except for the data name or filler clause, which is described first, all other data description clauses are described in alphabetical order on the following pages. Data Name or FILLER Clause A data name clause specifies the name of the data being described. The keyword, FILLER, implies that you are specifying an elementary item of the logical record being described that cannot be referenced explicitly. If this clause is omitted, the record is treated as though FILLER had been specified. In the FILE, WORKING-STORAGE, and LINKAGE SECTIONS, a data name must be the first word following the level number in each data description entry. Syntax. level-number [data-name-1] [FILLER ] Parameters. data-name-1 must be a valid user-defined COBOL word. Description. Although you may not refer to a FILLER item explicitly, the keyword FILLER may be used as a conditional variable (format 3) because the use of it in this manner does not require explicit reference to the FILLER item, but to its value. BLANK WHEN ZERO Clause The BLANK WHEN ZERO clause causes a numeric or numeric-edited data item to be filled with spaces when the value of the data item is zero. This clause is optional. If used, it may refer only to a numeric or numeric-edited elementary data item. When this clause is used with a numeric data item, the category of the data item is considered to be numeric-edited. Syntax. [BLANK WHEN ZERO]
NOTE This clause cannot be used for a numeric-edited data item whose PICTURE uses asterisks for zero suppression and replacement.
EXTERNAL Clause The EXTERNAL clause is a feature of the 1985 ANSI COBOL standard. The EXTERNAL clause specifies external attributes of a WORKING-STORAGE SECTION data description entry, the associated data record, and its subordinate data items. Syntax. IS EXTERNAL Description. The EXTERNAL clause can only be specified in data description entries in the WORKING-STORAGE SECTION whose level number is 01. The EXTERNAL clause and the REDEFINES clause must not be specified in the same data description entry. FILLER cannot be specified for any entry containing the EXTERNAL clause. Refer to Chapter 11 , "Interprogram Communication", for more detailed information. GLOBAL Clause The GLOBAL clause is a feature of the 1985 ANSI COBOL standard. The GLOBAL clause specifies that a 01 record description and its subordinate data items are available to all contained programs within a nested program in which the record is declared global. Refer to Chapter 11 , "Interprogram Communication," for more detailed information. Syntax. IS GLOBAL Description. The GLOBAL clause can be specified in data description entries in the WORKING-STORAGE SECTION where the level number is 01. FILLER cannot be specified for any entry containing the EXTERNAL clause. Refer to Chapter 11 , "Interprogram Communication", for more detailed information. JUSTIFIED Clause The JUSTIFIED clause allows you to right-justify alphabetic or alphanumeric data items. It cannot be used with numeric or edited data items, and only applies to elementary data items being used to receive data. This clause is optional. Syntax.
[]
Parameters. JUST is an abbreviation for JUSTIFIED. Description. Data is moved from a sending data item to the right justified receiving data item starting with the rightmost character of the sending data item. The rightmost character is placed in the rightmost character of the receiving data item. The next rightmost data item of the sending data item is then moved to the next rightmost character of the receiving data item. This process continues until either all of the sending data item has been moved, or the receiving data item is full. Note that a space in the sending data item is considered a valid character, no matter where it is within the sending data item. That is, spaces are not stripped from the sending item, even if they are in the rightmost positions of the sending item. When a receiving data item is described using this clause, and the sending data item is larger than the receiving item, the leftmost characters are truncated. When the receiving data item is longer than a sending item, the data is aligned at the rightmost character position in the receiving field, and unused characters to the left are filled with spaces. If the JUSTIFIED clause is not used, standard rules for aligning data within an elementary item are used. Example. Sending data item: HEWLETT-PACKARD COBOL II__ Receiving data item: 01 INFIRST PIC X(29) JUSTIFIED RIGHT. Resulting data item: ____HEWLETT-PACKARD COBOL II__ Assuming the same sending data item, but using a new receiving data item: Receiving data item: 01 NEWIN PIC X(14) JUSTIFIED RIGHT. Resulting data item: KARD COBOL II__ OCCURS Clause The OCCURS clause is used to define a table containing[REV BEG] up to seven dimensions.[REV END] Its use eliminates the need for separate entries to describe repeated data items, and provides information required for the application of subscripts or indices. Refer to Chapter 4 , "Tables", for a description of the formation and use of tables. Syntax. This clause has the following two general formats:
[]
The two formats of the OCCURS clause are described in the following paragraphs. The first format of the OCCURS clause is used to define a table of fixed length data items. Parameters to Format 1. integer-2 specifies the exact number of occurrences of the item being described. KEY IS phrase indicates that the repeated data is arranged in ASCENDING or DESCENDING order according to the values contained in data-name-3. data-name-3 must either be the name of the entry containing the OCCURS clause or the name of an entry subordinate to the entry containing the OCCURS clause (when first specified). Subsequent specification of data-name-3 must be subordinate to the entry containing the OCCURS clause. Data-name-3 may be qualified. INDEXED BY specifies one or more index names to be used when reference to the subject of this entry or items subordinate to it is done by indexing. index-name-1 not defined elsewhere in a program, and cannot be associated with any data hierarchy. Index names must be unique within a given program. The data names referred to by data-name-3 must be listed in their descending order of significance. If data-name-3 is not the same name as the item being described, then all of the items identified by data names in this phrase must be within the group item that is the subject of this entry, and must not contain an OCCURS clause. There must not be any entry containing an OCCURS clause between the items identified in the KEY IS phrase and the subject of this entry. The second format of the OCCURS clause is used to define a variable length table. Parameters to Format 2. integer-1 represents the minimum number of occurrences of the subject of the OCCURS clause. Integer-1 must be less than integer-2. integer-2 represents the maximum number of occurrences. This implies that only the number of occurrences is variable and not the length of the data item. data-name-4 represents an integer used to determine the number of occurrences of data items within the table. Therefore, the current value of the data item referenced by data-name-4 represents the number of occurrences. A data description entry containing this format of the OCCURS clause can only be followed, within the one record description, by data description entries subordinate to it. Data-name-4 must not be contained in that part of the record being described that starts at the first character of the first element of the table and continues to the end of the record. To illustrate, the two representations of records below show an allowable, and an unacceptable placement of the item referenced by data-name-4 in a record.
[]
Data-name-4, and its contents, must be described in a separate data description entry, and may be qualified. If the OCCURS clause is specified in a data description entry included in a record description entry containing the EXTERNAL clause, data-name-4, if specified, must reference a data item possessing the external attribute that is described in the same DATA DIVISION. [REV BEG] If the OCCURS clause is specified in a data description entry subordinate to one containing the GLOBAL clause, data-name-4, if specified, must be a global name and must reference a data item that is described in the same DATA DIVISION.[REV END] Because the current value of the data item referenced by data-name-4 represents the number of occurrences of a data item, it must be an integer in the range of values from integer-1 to integer-2. If the value of the integer represented by data-name-4 is reduced from a previous value, the contents of those data items whose occurrence numbers exceed this new value are unpredictable. When a group item has a subordinate entry that specifies format 2 of the OCCURS clause, only that part of the group item specified by the value of data-name-4 is used. The KEY IS and INDEXED BY phrases follow the rules given for format 1. The OCCURS clause cannot be specified in a data description entry having an 01, 66, 77, or 88 level number. The OCCURS clause cannot be used in a description entry for an item whose size is variable. The size of an item is variable if the data description of any subordinate item contains format 2 of the OCCURS clause. In other words, this restriction means that no OCCURS clause using the DEPENDING ON phrase can be used in the description of an item subordinate to an item that also uses either format of the OCCURS clause. Examples. For example, the following two records are allowed: 01 ROAD. 02 SURFACE OCCURS 1 TO 12 TIMES DEPENDING ON SIZER. 03 SIDE OCCURS 10 TIMES PIC X(9). Allowed. 01 ROAD. 02 SURFACE OCCURS 10 TIMES. 03 SIDE OCCURS 4 TIMES PIC X(9). But, the following two records are not allowed: 01 ROAD. Not allowed. 02 SURFACE OCCURS 10 TIMES. 03 SIDE OCCURS 1 TO 8 TIMES DEPENDING ON SIZER PIC X(9). 01 ROAD. 02 SURFACE OCCURS 1 TO 10 TIMES DEPENDING ON SIZER. Not allowed. 03 SIDE OCCURS 1 TO 8 TIMES DEPENDING ON SIZEUP PIC X(9). The name of the data item being described must be either subscripted or indexed whenever it is referred to in any way other than with the SEARCH or USE FOR DEBUGGING statements. Also, if the name of the data item being described is the name of a group item, then all data names belonging to the group must be subscripted or indexed whenever they are used as operands, except as the object of a REDEFINES clause. Except for the OCCURS clause itself, all data description clauses associated with an item whose description includes an OCCURS clause apply to every occurrence of the item being described. [REV BEG] If a data item possessing the global attribute includes a table accessed with an index, that index also possesses the global attribute. See[REV END] Chapter 11 , "Interprogram Communication," for more detailed information. PICTURE Clause The PICTURE clause describes the category, length, and editing requirements for an elementary item. It applies only to elementary data items and must be used for every elementary data item. It is not allowed for an index data item. Syntax.
[]
Parameters. PICTURE and PIC equivalent. character-string a set of up to 30 characters, arranged in certain allowable combinations; these combinations determine the category of the elementary item. Description. You can define any of five categories of data with the PICTURE clause. The five categories of data are: * Alphabetic * Numeric * Alphanumeric * Alphanumeric-edited * Numeric-edited Alphabetic Data. Alphabetic data consists of upper and lowercase letters from the English alphabet, and one or more blanks. When you wish to define the characteristics of an alphabetic data item, the character string must consist of a combination of the letters A and/or B and, optionally, one or more nonnegative integers in parentheses. The letter A represents a character of the alphabet or a space. The letter B represents a blank (or a space). The integers are repetition factors and are used to specify one or more occurrences of A or B in the picture. To describe an alphabetic data item that consists of six alphabetic characters, three spaces, and then twelve more alphabetic characters (or blanks), the following PICTURE clauses could be used, and are equivalent: PICTURE IS AAAAAABBBAAAAAAAAAAAA PIC A(6)B(3)A(12) Numeric Data. Numeric data consists of a combination of the Arabic numerals 0 through 9, optionally including the positive or negative sign, or a representation of an operational sign as defined in the SIGN clause. Note that a decimal point is not part of the possible set of characters allowed in forming numeric data for a COBOL program. You must specify the data without a decimal point. Use the V character of the PICTURE clause to indicate where the decimal point belongs. The size of a numeric data item can be from one to 18 digits long. When you wish to define the characteristics of a numeric data item, the picture clause you use must consist of only the symbols 9, P, S, V, and (in conjunction with the 9 and P symbols only) one or more repetition factors as described under the heading "Alphabetic Data", above. The symbol 9 represents the character position that is to contain a numeral. The symbol S indicates the presence of an operational sign, but not necessarily its position within a numeric data item. It must be the leftmost character in the picture of the data item being described and can appear only once in a given picture clause. The S symbol is not counted in determining the size of an elementary data item unless the data item is subject to a SIGN clause using the SEPARATE CHARACTER phrase. The symbol V is used to indicate the location of the assumed decimal point in numeric data. Like the S symbol, it may only appear once in any given picture clause. Because the V does not represent a character position, it is not counted in the size of the elementary data item. Note also that if the V appears as the rightmost character in a character string, it is redundant.


MPE/iX 5.0 Documentation