[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index

5.1.1 Record Description Entries

Logical records do not have to be subdivided; however, they often are. Subdivision can continue for each of the record's parts, allowing progressively more detailed data definition.

The basic subdivision of a record is the elementary data item (or elementary item), which you define by specifying a PICTURE clause (except for COMP-1 or COMP-2). As the term implies, elementary items are never subdivided. A logical record consists of one or more sets of elementary items, or is itself an elementary item.

A group data item (or group item) is a data set within a record that contains other subordinate data items. The lowest-level group item is always a named sequence of one or more elementary items. Group items can combine to form more inclusive group items. Therefore, an elementary item can be subordinate to more than one group item in the record.

Figure 5-1 represents a personnel record that illustrates how elementary and group items can be related in a record hierarchy. The record contains three group items directly subordinate to the top level: Identification Data, History, and Payroll Data. The first group item, Identification Data, directly contains two elementary items, Name and Job Title, and two other group items, Employee Number and Address. The group item, Employee Number, contains two elementary items: Department Code and Badge Number. The group item, Address, contains four elementary items: Street, City, State, and ZIP Code. The elementary item, City, belongs to three group items. It is subordinate to Address, Identification Data, and Personnel Record. The second group item, History, directly contains three elementary items: Hire Date, Last Promotion Date, and Termination Date. The third group item, Payroll Data, also directly contains two elementary items: Current Salary and Previous Salary.

Figure 5-1 Hierarchical Record Structure


5.1.2 Level-Numbers

Record description entries use a system of level-numbers to specify the hierarchical organization of elementary and group items. Level-numbers that specify hierarchical structure can range from 01 to 49.

The record is the most inclusive data item; that is, there is no hierarchical relationship between one record description entry and any other. However, there is a hierarchical relationship between a group item and its subordinate group or elementary items. The level-number for records is 01. Less inclusive data items have greater (although not necessarily consecutive) level-numbers.

All items subordinate to a group item must have level-numbers greater than the group's level-number. In a record description, a group item is delimited by the next level-number that is less than or equal to that group's level number.

Figure 5-2 shows how level-numbers specify hierarchical structure and how the presence of the PICTURE clause defines an elementary item. Although line indentation can make record descriptions easier to read, it does not affect record structure; only the level-number values specify the hierarchy. The ellipsis (...) indicates that parts of the program line have been omitted.

Figure 5-2 Level-Number Record Structure


Three special level-numbers---66, 77, and 88---neither specify hierarchical structure nor actually indicate level. Rather, they define special types of data entries:

  • Level-number 66 identifies RENAMES items, which regroup other data items. See the Section 5.3.41 clause for more information.
  • Level-number 77 specifies noncontiguous (elementary) items in the Working-Storage and Linkage Sections. These data items are not subdivisions of other items and cannot be subdivided. For all other purposes, they are identical to level 01 elementary entries.
  • Level-number 88 associates condition-names with values of a corresponding data item (the conditional variable).
    See Chapter 1, Overview of the COBOL Language, for more information on condition-names.

5.1.3 Multiple Record Description Entries for the Same Data

Example 5-1 shows a sample file description entry (FD) that contains three record description entries. The three record description entries define three logical templates the program can impose on a record to access data from it.

Example 5-1 Multiple Record Definition Structure

FD MASTER-FILE.
01 T1.
   02  T1-ACCOUNT-NO        PIC 9(6).
   02  T1-TRAN-CODE         PIC 99.
   02  T1-NAME              PIC X(13).
   02  T1-BALANCE           PIC 9(5)V99.
   02  REC-TYPE             PIC XX.
01 T2.
   02  T2-ACCOUNT-NO        PIC 9(6).
   02  T2-ADDRESS.
       03 T2-STREET         PIC X(15).
       03 T2-CITY           PIC X(7).
   02  REC-TYPE             PIC XX.
01 RECORD-TYPE.
   02                       PIC X(28).
   02  REC-TYPE             PIC XX.

The three record description entries in Example 5-1, T1, T2, and RECORD-TYPE, each define a fixed-length record of 30 characters. Once the program reads a record, it can use the last two characters (REC-TYPE) to determine which record description entry to use.

5.2 Physical Concepts of Data Storage

COBOL programs describe files and data in physical terms for storage on input-output media. The physical description of data includes the following information:

  • The mapping and grouping of logical records within the structure of the file storage medium
  • The unit used to transfer records to and from your program
  • The size and storage format of an elementary data item

The size of a physical record and the way it is recorded depend on the hardware device involved in an input or output operation. For example, tape and disk media store physical records differently. On tape, a physical record is written between interrecord gaps. On disk, a physical record is written in multiple units of a fixed number of bytes, which is determined by the hardware and operating system involved.

On OpenVMS systems, the term used for a physical record differs according to file organization. A physical record in a sequential file is called a block. A physical record in a relative or indexed file is called a bucket. A block or bucket corresponds to the unit used by the I/O system software to transfer records from a file to your program (and vice versa). The number of records (in logical terms) actually transferred by an input-output operation depends on the following:

  • The block size specified by the BLOCK CONTAINS clause (tape files only)
  • The number of logical records contained in a physical record

The maximum physical record size depends on file organization and device. On OpenVMS systems, the maximum physical record sizes for sequential files on tape devices and for sequential, indexed, and relative files on disk are shown in terms of number of bytes in Table 5-1.

Table 5-1 Maximum Physical Record Size for Tape and Disk Devices
Type of File Magnetic Tape Devices Disk
Sequential 65,535 bytes 65,024 bytes
Indexed N/A 32,234 bytes
Relative N/A 32,255 bytes <>

Note

A compile-time informational diagnostic appears if the physical record size exceeds 65,024 bytes for a sequential file. However, HP COBOL programs are device-independent. Therefore, a fatal run-time error can also occur if the file is assigned to disk when the program runs.

5.2.1 Categories and Classes of Data

The size and storage format of an elementary data item depend upon what class and category of data it represents and how that data can be used. A data item's PICTURE clause determines its class and category. The item's PICTURE clause and USAGE clause, in combination, specify its size and storage format. See the Section 5.3.37 and Section 5.3.52 clauses for more information.

When an arithmetic or data-movement statement transfers data into an elementary item, the category of the item affects the way the data is positioned in storage. The COBOL Standard Alignment Rules (see Section 5.2.2) specify the relationship between category and positioning.

Depending on the symbols contained in its PICTURE clause, every elementary item belongs to one of the classes and categories of data items shown in Table 5-2. COMP-1, COMP-2, index data items, and index-names do not have PICTURE clauses; the format of these elementary items is specified by the compiler and they belong to the numeric category.

The class of a group item is treated as alphanumeric regardless of the class of elementary items subordinate to it. Therefore, your program statements should not specify a group item when a numeric item is expected or required.

Table 5-2 Classes and Categories of Data Items
Level Class Category
 
Alphabetic

Alphabetic
   
Elementary Numeric Numeric
   
 
Alphanumeric
Numeric Edited
Alphanumeric Edited
Alphanumeric
 


Group


Alphanumeric
Alphabetic
Numeric
Numeric Edited
Alphanumeric Edited
Alphanumeric


Previous Next Contents Index