Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Concept of computer-independent data description

To make data as computer-independent as possible, the characteristics and properties of the data are described in a format which is largely independent of the concrete representation in the computer or on the external medium.

The following applies for literals:

  • The content of alphanumeric non-hexadecimal literals is taken over unchanged for the runtime.

  • The content of national non-hexadecimal literals is always converted to UTF-16 representation for the runtime.

  • Hexadecimal literals always specify the final bit pattern that is to be used at runtime.

1. Concept of logical record and file

The logical characteristics of a record or a file differ from the way in which the data is physically stored in the computer.

  • Physical aspects of a file

    The physical aspects of a file are determined by the way in which the data is stored on the input or output medium. They include such features as:

    • the grouping of logical records, taking into account the physical limitations of the storage medium.

    • the manner in which a file may be identified.

  • Conceptual characteristics of a file

    The conceptual characteristics of a file are determined by the structures which the user specifies by data definitions. The input-output statements in a COBOL program refer to logical records.

    It is extremely important to distinguish between a physical record and a logical record.

    • A physical record (or block) is a unit of information whose size and recording mode provide for optimum data storage on an input or output medium for a particular computer installation. The size of a physical record is machine-dependent and bears no direct relationship to the size of the logical file information.

    • A logical record (or simply record) is a group of related data which can be uniquely identified and treated as a unit, and can be read from or written to a file. A block may contain several records.

    The term "record" is not restricted to data stored on an external data medium, but can be applied to the definition of working storage for data created internally during program execution.

    In this manual, references to "records" always mean to logical records.

2. Level concept

The level concept permits the structuring of a logical record. Data processed by a COBOL program can be described as elementary items, group items, records and files.

  • Elementary items

    An elementary item is the smallest unit of data bearing a name, i.e. it is not divisible into further elementary items. An elementary item is mostly described with a PICTURE clause (for exceptions see section "Data description entry formats").

    The length of an elementary item must not exceed 131 071 bytes.

  • Group items

    Several elementary items combined form a group item. Thus, a number of elementary items may be addressed simultaneously under the name of the group item. Each group consists of one or more elementary items. Groups, in turn, may be contain further more group items.Consequently, an elementary item may belong to more than one group item (see figure 1 and figure 2). The name of a group item must not be described with the PICTURE clause.

  • Records

    A record is a data item which is not subordinate to another data item. It consists of one group items, or it is itself an elementary item. The description of a record must start in Area A.

  • Level-numbers

    Data is divided into various levels. These levels are indicated by means of level-numbers. The numbers 01 to 49 are allowed as level-numbers. In addition, there are special level-numbers: 66, 77, and 88. In a compilation unit, every level-number must be given a separate entry.

    Since a record represents the largest organizational unit, level-numbers for records start at 01. Hierarchically subordinate items are assigned numerically higher level numbers (from 02 to 49). The level-number of a subordinate data item must be greater than that of a higher-ranking data item by one or more units. Once an elementary item has been described, only those level-numbers which have already appeared in the record description entry are permitted.

Example 2-8

right:

wrong:

01 DATA RECORD.
   05  GROUP-ITEM-1.
       10  ELEMENTARY-ITEM-11 ...
       10  ELEMENTARY-ITEM-12 ...
       10  ELEMENTARY-ITEM-13 ...
   05  GROUP-ITEM-2.
       10  ELEMENTARY-ITEM-21 ...
       10  ELEMENTARY-ITEM-22 ...
01 DATA RECORD.
   05 GROUP-ITEM-1.
       10  ELEMENTARY-ITEM-11 ...
       10  ELEMENTARY-ITEM-12 ...
       10  ELEMENTARY-ITEM-13 ...
   03  GROUP-ITEM-2.
       10  ELEMENTARY-ITEM-21 ...
       10  ELEMENTARY-ITEM-22 ...

There are three types of data for which no level concept exists. These are assigned the level numbers 66, 77, and 88:

  • Level number 66 is given to the names of data items described with the RENAMES clause (see the section "RENAMES clause").

  • Level number 77 is given to structure-independent data items of the WORKING-STORAGE SECTION or LINKAGE SECTION (see the section "Level number").

  • Level number 88 is given to the explanation of condition-names (see the section "VALUE clause").

Further rules are described in the section "Level number".

Figure 1: Relationship between group items and elementary items in a record

01 RECORD-A.
   05 GROUP-ITEM-1.
      07 GROUP-ITEM-2.
         08 GROUP-ITEM-3.
            10 ELEMENTARY-ITEM-1...
            10 ELEMENTARY-ITEM-2...
         08 ELEMENTARY-ITEM-3...
      07 GROUP-ITEM-4.
         08 ELEMENTARY-ITEM-4...
         08 ELEMENTARY-ITEM-5...
   05 ELEMENTARY-ITEM-6...

Figure 2: Group items and elementary items in a record


Figure 1 shows the structure of a sample record; Figure 2 demonstrates how to use level numbers to represent this structure in the record description entry. In this example, GROUP-ITEM-3 and ELEMENTARY-ITEM-3 are a subordinate part of GROUP-ITEM-2; similarly, GROUP-ITEM-2 and GROUP-ITEM-4 are a subordinate part of GROUP-ITEM-1.

3. Classes and categories of data and literals

Each data item is assigned a class and a category.

The class and category of a strongly typed group item are the type name which is specified in the TYPE clause of the group item.

The class and category of a group item which is not strongly typed are

  • alphanumeric for an alphanumeric group

  • national for a national group

An alphanumeric group is treated as if it has USAGE DISPLAY.

The class and category of a function are defined by the function type (see “Function types” in section "General").
The category of an elementary data item depends on its definition.
The classes and categories of literals are defined in the section "Literals".

Table 7 below illustrates the relationship between the classes and categories of elementary data items.

Class

Category

alphabetic

alphabetic

alphanumeric

numeric edited
alphanumeric edited
alphanumeric

index

index

national

national

numeric

numeric

object

object reference

pointer

data pointer
program pointer

Table 7: Classes and categories of elementary items


The following subsections describe the data items in the various categories.

  • Alphabetic data items

    An alphabetic data item is a data item whose contents can be any combination of the 52 uppercase and lowercase letters of the alphabet, plus the space character. Each alphabetic character is stored in its own byte in working storage.

    The PICTURE character-string for alphabetic items contains only the symbol A.
    The data format of alphabetic items is always DISPLAY.

    An alphabetic data item may be specified wherever an elementary alphanumeric item is permitted as an operand. Unless otherwise specified, it is treated as if it were an alphanumeric item.

  • Alphanumeric edited items

    An alphanumeric edited item describes the editing of an alphanumeric value. When an alphanumeric edited item is a receiving item for a MOVE statement, the data being moved into the item is edited according to the PICTURE character-string specified for the item.

    The picture-string of an alphanumeric edited item is restricted to certain combinations of the following characters: A, / (slash), X, 9, 0 (zero), and B (see the section "PICTURE clause").

    The contents of an alphanumeric edited item are allowable characters chosen from the EBCDIC character set.

    The data format of an alphanumeric edited item is always DISPLAY.

  • Alphanumeric items

    An alphanumeric item is one whose contents are any characters from the EBCDIC set.

    Its picture-string is restricted to combinations of the symbols A, X, and 9. The item is treated as if its picture-string contained all X’s.

    A picture-string which contains all A’s or all 9’s does not define an alphanumeric item. The data format of an alphanumeric item is always DISPLAY.

  • Data pointer

    A data pointer (also simply referred to as pointer) is an elementary item in which a data address can be stored.

  • Index items

    Each of the following is an index item:

    • An elementary item which is described explicitly or implicitly with USAGE INDEX

    • An index function

  • National items

    Each of the following is a national item:

    • An elementary item which is described as national by its PICTURE character-string

    • An elementary item without PICTURE clause which is described with a format 1 VALUE clause and a national literal

    • An elementary item which is defined explicitly or implicitly with USAGE NATIONAL

    • A group item which is described explicitly or implicitly with a GROUP-USAGE NATIONAL clause

    • A national function

  • Numeric edited items

    A numeric edited item describes the editing of a numeric value. When a numeric edited item is a receiving item for a MOVE, the data coming into the item is edited according to the picture-string specified.

    The picture-string of a numeric edited item is restricted to certain combinations of the symbols B, / (slash), P, V, Z, 0 (zero), 9, , (comma), . (decimal point), *, +, -, CR, DB and $ (currency sign). The allowable combinations are determined from editing rules and the order or precedence of symbols (see the section "PICTURE clause"). The maximum number of digits that may be represented in a picture-string for a numeric edited item is 31.

    Data is stored one character per byte. The contents of a character position that represents a digit must be one of the numerals 0 through 9.

    The data format of a numeric edited data item is always DISPLAY.

  • Numeric items

    There are two types of numeric data items, fixed-point items and floating-point items. For the internal representation of numeric items, see table 17 in section "COMPUTATIONAL-3 phrase or PACKED-DECIMAL phrase".

     

    Fixed-point data items

    A fixed-point data item is a numeric data item in which the operational decimal point is assumed to be present in every value or to be maintained at a fixed position relative to the beginning or end of the storage area reserved for the data item. The contents of a fixed-point data item must be comprised of the digits 0 through 9, provided the SIGN clause is not specified. If the SIGN clause is specified, the contents may contain a +, - or other representations of the sign in addition to the above-mentioned digits. If the picture-string contains an S for a fixed-point data item, the contents of the data item are treated as positive or negative, depending on the operational sign. If the picture-string does not contain an S, the contents of the data item are treated as an absolute value. treated as an absolute value.

    Picture-strings for fixed-point items may contain the symbolic characters 9, P, S and V only.

    COBOL recognizes three types of fixed-point numbers:

    external decimal(USAGE IS DISPLAY)
    binary(USAGE IS COMPUTATIONAL or COMPUTATIONAL-5 or USAGE IS BINARY)
    internal decimal(USAGE IS COMPUTATIONAL-3 or USAGE IS PACKED-DECIMAL)

    The differences between these three types are described under the section "USAGE clause".

    Floating-point data items

    A floating-point data item is a numeric data item whose decimal point is movable, i.e. it can be located at various positions and is defined by specifying a base-10 exponent. The base thus raised to a particular power serves as the coefficient of a fixed-point number (mantissa) thereby representing the floating-point number.

    Floating-point data items are only used for data whose potential value range is too large for fixed-point representation.

    There are two kinds of floating-point data items: external floating-point data items and internal floating-point data items.

    External floating-point data items

    The picture-string for an external floating-point data item can contain the characters 9, . (decimal point), V, E, + and -. Except for V, each character occupies one byte of memory, and is contained in each printout (see "PICTURE clause" and "USAGE clause" for further details).

    The data format of an external floating-point data item is always DISPLAY.

    Internal floating-point data items

    There are two kinds of internal floating-point data items:

    • single-precision (USAGE IS COMPUTATIONAL-1), with a length of 4 bytes and

    • double-precision (USAGE IS COMPUTATIONAL-2), with a length of 8 bytes.

    Both encompass the same value range. A single-precision data item permits precision to 7 decimal digits. A double-precision data item allows precision to 16 decimal digits.

    A PICTURE clause is prohibited for internal floating-point data items; the length of this kind of data item is determined by its USAGE clause.

     

  • Object and object reference

    An object reference is an implicitly or explicitly defined data item. The content of the object reference uniquely references an object and its associated information.

  • Program pointer

    A program pointer is an elementary item in which the address of a program can be stored.

4. Algebraic signs

There are two categories of algebraic signs:

  • operational signs, which are associated with signed numeric items and signed numeric literals to specify their algebraic properties

  • editing signs, which occur e.g. in edited reports in order to indicate the sign of a data item.
    Editing signs are inserted in a data item by means of the sign control character of the relevant picture-string (see "PICTURE clause").

5. Alignment of data

The alignment of data within elementary data items depends on the category of the receiving item.

  • Numeric data items

    If the receiving item is described as a numeric item, the data being sent is aligned on the decimal point and is moved to the digit positions of the receiving item. If the data being sent is shorter than the receiving item, the unused digit positions are filled with zeros. If the data being sent is longer than the receiving item, it is truncated from the left or right as appropriate.
    If an assumed decimal point is not supplied explicitly, the receiving item is treated as if it had an assumed decimal point immediately following its rightmost digit; alignment and moving are as described above.

  • Numeric edited data items

    If the receiving item is a numeric edited item, alignment and moving of the data being sent take place as in the case of numeric receiving items; leading zeros can be replaced by other characters through special editing specifications.

  • Alphanumeric, alphanumeric edited, alphabetic and national data items

    If the receiving item is alphanumeric (other than numeric edited), alphanumeric edited, alphabetic or national, then the data being sent is moved from left to right into the character positions of the receiving item. If the data being sent is shorter than the receiving item, the unused character positions are filled with spaces according the receiving item class. If the data being sent is longer than the receiving item, the excess characters of the data being sent are truncated.
    If the JUSTIFIED clause is specified for the receiving item, refer to the section "JUSTIFIED clause".

  • Data item alignment for accelerated program execution

    Particular data (in arithmetic or subscripting operations) can be processed more rapidly if the data is aligned on natural boundaries (halfword, word, doubleword).
    The object program requires additional machine instructions for accessing and storing data if parts of two or more data items occur between two adjacent natural boundaries or if certain natural boundaries divide a single item.
    Data items whose alignment on these natural boundaries is such that they do not require additional machine instructions, are defined as "synchronized". Data items of the classes index, object and pointer are always aligned (see table 16 “Data item alignment” in section "SYNCHRONIZED clause").

    The user has two means of achieving this form of alignment:

    • using the SYNCHRONIZED clause (see the section "SYNCHRONIZED clause"),

    • suitably organizing the data, allowing for the natural boundaries.
      See the next section for details.