COBOL/400 Language Help

Format 2 (RENAMES Clause -- Level-66 Entry)

Description
Format 2 (RENAMES Clause -- Level-66 Entry) regroups previously defined items by specifying alternative, possibly overlapping, groupings of elementary data items.

You must use the level number 66 for data description entries that contain the RENAMES clause. A level-66 entry cannot rename another level-66 entry, nor can it rename a level-01, level-77, or level-88 entry.

One or more RENAMES entries can be written for a logical record. All RENAMES entries associated with one logical record must immediately follow that record's last data description entry.

Level number 66 and data-name-1 are not a part of the RENAMES clause itself and are included in the format below only for clarity.

Format 2 (RENAMES Clause -- Level-66 Entry)
 
->->--66 data-name-1 RENAMES data-name-2--*---------------------------*---><-
                                        *--THROUGH--*--data-name-3--*
                                        *--THRU-----*

data-name-1

Data-name-1 identifies an alternative grouping of data items.

You cannot use data-name-1 as a qualifier; it can be qualified only by the names of level indicator entries or level-01 entries.

data-name-2, data-name-3

Data-name-2 and data-name-3 identify the original grouping of data items; that is, they must name elementary or group items within the associated level-01 entry, and must not be the same data-name. Both data-names may be qualified.

The OCCURS clause must not be specified in the data entries for data-name-2 and data-name-3, or for any group entry to which they are subordinate. In addition, the OCCURS DEPENDING ON clause must not be specified for any item defined between data-name-2 and data-name-3.

When data-name-3 is specified, data-name-1 is treated as a group item that includes all elementary items:

The keywords THROUGH and THRU are equivalent.

The leftmost character in data-name-3 must not precede the leftmost character in data-name-2; the rightmost character in data-name-3 must not precede the rightmost character in data-name-2. This means that data-name-3 may not be totally subordinate to data-name-2.

When data-name-3 is not specified, all of the data attributes of data-name-2 become the data attributes for data-name-1. That is:

Level-Number

Description
Level-number specifies the hierarchy of data within a record and identifies special-purpose data entries.

In Format 1, level-number can be any number from 01-49 or 77.

You can substitute single-digit level-numbers 1 through 9 for level-numbers 01 through 09.

data-name

Data-name explicitly identifies the data being described. If you specify a data-name, it identifies a data item used in the program. The data-name must be the first word following the level-number.

FILLER

FILLER is a data item that is not explicitly referred to in a program. If you specify FILLER (an optional keyword), it must be the first word following the level-number.

If you omit the data-name or the keyword FILLER, the data item being described is treated as though FILLER had been specified.

BLANK WHEN ZERO Clause

Description
The BLANK WHEN ZERO clause specifies that an item contains nothing but spaces when its value is zero. You can specify the BLANK WHEN ZERO clause only for elementary numeric or numeric-edited items. These items must be described, either implicitly or explicitly, as USAGE IS DISPLAY.
->->---BLANK*----*----ZERO---------><-
          *WHEN*

JUSTIFIED Clause

Description
The JUSTIFIED clause overrides standard positioning rules for a receiving item of the alphabetic or alphanumeric categories. You can specify JUSTIFIED only at the elementary level.

You can specify the JUSTIFIED clause for alphanumeric-edited items, but not for numeric or numeric-edited items.

When you specify the JUSTIFIED clause for a receiving item, the data is aligned at the rightmost character position in the receiving item. Also:

You cannot specify the JUSTIFIED clause:

The JUSTIFIED clause does not affect initial values, as determined by the VALUE clause.

->->---*--JUSTIFIED--*-*-----*---><-
     *--JUST-------* *RIGHT*

OCCURS Clause

Description
The OCCURS clause specifies tables whose elements can be referred to by indexing or subscripting. The OCCURS and USAGE IS INDEX clauses are the two Data Division clauses used for table handling.

An item whose usage is POINTER can contain an OCCURS clause, or be subordinate to an item declared with an OCCURS clause.

The OCCURS clause cannot be specified in a data description entry that has a level number of 01, 66, 77, or 88. The OCCURS clause has two formats:

Format 1 (Fixed-Length Tables)

Description
Format 1 of the OCCURS clause specifies fixed-length tables.
Format 1 (Fixed-Length Tables)
 
->->--OCCURS integer-2-*-------*---------------->
                     *-TIMES-*
 
  *---------------------------------------------*
  V                                             +
->-*---------------------------------------------*---------->
  +                               *-----------* +
  +                               V           + +
  *-*-ASCENDING--*-*-----**----*--data-name-2-*-*
    *-DESCENDING-* *-KEY-**-IS-*
 
->-*--------------------------------*-----------------------><-
  +                *------------*  +
  +                V            +  +
  *-INDEXED-*----*-index-name-1-*--*
            *-BY-*
 

integer-2

Integer-2 represents the exact number of occurrences. Integer-2 must be between 1 and 3 000 000 bytes.

data-name-2

Data-name-2 must be the name of the subject entry, or the name of an entry subordinate to the subject entry.

If data-name-2 names the subject entry, that entire entry becomes the ASCENDING/DESCENDING KEY, and is the only key that may be specified for this table element.

If data-name-2 does not name the subject entry, then data-name-2:

ASCENDING/DESCENDING KEY Phrase

With the ASCENDING/DESCENDING KEY phrase, data is arranged in ascending or descending order, depending on the keyword specified, according to the values contained in data-name-2. The data-names are listed in their descending order of significance.

When you specify the ASCENDING/DESCENDING KEY phrase, the following rules apply:

INDEXED  The INDEXED BY phrase specifies the indexes that can be used with this table. The INDEXED BY phrase is required if you use indexing to refer to this table element.

index-name-1  Index-name-1 must follow the rules for the formation of user-defined words. At least 1 character must be alphabetic.

Each index-name specifies an index to be created by the compiler for use by the program. These index-names are not data-names and are not identified elsewhere in the COBOL program. Instead, they can be regarded as private special registers for the use of this object program only. As such, they are not data, or part of any data hierarchy. Each index-name must be unique.

Format 2 (Variable-Length Tables)

Description
The OCCURS DEPENDING ON clause specifies variable-length tables.
Format 2 (Variable-Length Tables)
 
->->--OCCURS--integer-1 TO integer-2---*-------*------------->
                                     *-TIMES-*
 
->--DEPENDING-*----*data-name-1---------------------------->
             *-ON-*
 
    *---------------------------------------------*
    V                                             +
->---*---------------------------------------------*-------->
    +                               *-----------* +
    +                               V           + +
    *-*-ASCENDING--*-*-----**----*-data-name-2-*-*
      *-DESCENDING-* *-KEY-**-IS-*
 
->---*--------------------------------*---------------------><-
    +                *------------*  +
    +                V            +  +
    *-INDEXED-*----*-index-name-1-*--*
              *-BY-*

integer-1

Integer-1 represents the minimum number of occurrences. Integer-1 must be greater than or equal to zero and less than integer-2.

integer-2

Integer-2 represents the maximum number of occurrences. Integer-2 must be no more than 32 767.

DEPENDING

The OCCURS DEPENDING ON clause specifies variable-length tables.

The object of the OCCURS DEPENDING ON clause must not occupy any storage position within the range of any table, that is, any storage position from the first character position in the table through the last character position in the table.

data-name-1

Data-name-1 specifies the object of the OCCURS DEPENDING ON clause, that is, the data item whose current value represents the current number of occurrences of the subject item.

PICTURE Clause

Description
The PICTURE clause specifies the general characteristics and editing requirements of an elementary item. You must specify a PICTURE clause for every elementary item except an index data item or the subject of the RENAMES clause.

The PICTURE character string, which may contain a maximum of 30 characters, is made up of certain COBOL characters used as symbols. The allowable combinations determine the category of the elementary data item.

Allowable characters include: A, B, P, S, V, X, Z, 9, 1, 0, /, , (comma), . (period), +, -, CR, DB, *, and $.

->->---*--PICTURE-*-----*----*--character-string--------------><-
     *--PIC-----*     *-IS-*
 

REDEFINES Clause

Description
The REDEFINES clause allows you to use different description entries to describe the same computer storage area. When you specify the REDEFINES clause, it must be the first entry following data-name-1 or FILLER. If you do not specify data-name-1 or FILLER, REDEFINES must be the first entry following the level-number.

The level-numbers of data-name-1 and data-name-2 must be identical and must not be level 66 or level 88.

->->--level-number--*---------------*-REDEFINES data-name-2---><-
                  *--data-name-1--*
                  *--FILLER-------*

data-name-1

Data-name-1, FILLER identifies an alternate description for the same area and is the redefining item or the REDEFINES subject.

data-name-2

Data-name-2 is the redefined item or the REDEFINES object.

FILLER

FILLER identifies an alternate description for the same area and is the redefining item or the REDEFINES subject.

Specifying FILLER does not affect the running of the program; the program runs as though nothing were specified.

When you specify the REDEFINES clause, it must immediately follow data-name or FILLER, if either is specified. If you do not specify data-name or FILLER, the REDEFINES clause must immediately follow the level-number.

LIKE Clause

Description
The LIKE clause allows you to define the PICTURE, USAGE, and SIGN characteristics of a data item by copying them from a previously defined data item. It also allows you to make the length of the data item you define different from the original item. For Boolean data, you cannot change the length of the data item using this clause.

You cannot use the LIKE clause to:

You can specify one or more other clauses before or after the LIKE clause:

You can specify BLANK WHEN ZERO only if it has not previously been inherited.

You cannot use the LIKE clause with:

->->------LIKE---data-name---*-----------*-----------------><-
                           *-(integer)-*
 

data-name

Data-name refers to an elementary item, a group item, or an index-name.

integer

Integer specifies the difference in length between the new and existing items. If a blank or a + precedes the integer, the new item is longer. If a - precedes the integer, the new item is shorter.

SIGN Clause

Description
The SIGN clause specifies the position and the mode of representation of the operational sign for a numeric entry. You can specify the SIGN clause only for a signed numeric data description entry (that is, one whose PICTURE character-string contains an S) or for a group item that contains at least one such elementary entry. You must specify, explicitly or implicitly, USAGE IS DISPLAY.
->->--*--------------*-*-LEADING--*-*--------------------*----><-
    *-SIGN--*----*-* *-TRAILING-* *SEPARATE-*---------*-*
            *-IS-*                          *CHARACTER*

SEPARATE CHARACTER Phrase

If you specify the SEPARATE CHARACTER phrase:

If you do not specify the SEPARATE CHARACTER phrase:

SYNCHRONIZED Clause

Description
The SYNCHRONIZED clause specifies the alignment of an elementary item on a natural boundary in storage. The SYNCHRONIZED clause may appear only at the elementary level. You cannot use it for group items.
->->---*--SYNCHRONIZED--*--*---------*------------------------><-
     *--SYNC----------*  *--LEFT---*
                         *--RIGHT--*

The effect of the SYNCHRONIZED clause is dependent on the USAGE you specify for an item.
If the USAGE is... The SYNCHRONIZED clause...
DISPLAY is syntax-checked but does not affect execution
PACKED-DECIMAL is syntax-checked but does not affect execution
COMPUTATIONAL-3 is syntax-checked but does not affect execution
BINARY:
PIC S9(1) through S9(4) aligns the data item at a multiple of 2 relative
to the beginning of the record
PIC S9(5) through S9(18) aligns the data item at a multiple of 4 relative
to the beginning of the record
COMPUTATIONAL-4 functions the same as for USAGE BINARY
COMPUTATIONAL is syntax-checked but does not affect execution
INDEX is not permitted

LEFT

The LEFT phrase specifies that the elementary item is to be positioned so that it will begin at the left character position of the natural boundary in which the elementary item is placed.

When specified, the LEFT phrase is syntax checked, but has no effect on the execution of the program.

RIGHT

The RIGHT phrase specifies that the elementary item is to be positioned so that it will terminate at the right character position of the natural boundary in which it has been placed.

When specified, the RIGHT phrase is syntax-checked, but has no effect on the execution of the program.

USAGE Clause

Description
The USAGE clause specifies the format of a data item in computer storage.

You can specify the USAGE clause for a data description entry at any level. However, if you specify USAGE at the group level, USAGE applies to each elementary item in the group. The usage of an elementary item must not contradict the usage of a group to which the elementary item belongs.

The USAGE clause specifies the format in which data is represented in storage. The format may be restricted if certain Procedure Division statements are used.

When you do not specify the USAGE clause at either the group or elementary level, it is assumed that usage is DISPLAY.

->->---*------------*--*--BINARY-----------*---><-
     *--USAGE-*--**  *--COMPUTATIONAL----*
              *IS*   *--COMP-------------*
                     *--COMPUTATIONAL-3--*
                     *--COMP-3-----------*
                     *--COMPUTATIONAL-4--*
                     *--COMP-4-----------*
                     *--DISPLAY----------*
                     *--INDEX------------*
                     *--PACKED-DECIMAL---*
                     *--POINTER----------*

BINARY

Specify BINARY for binary data items. Such items have a decimal equivalent consisting of the decimal digits 0 through 9, plus a sign. Negative numbers are represented as the two's complement of the positive number with the same absolute value.

PACKED-DECIMAL

Specify the PACKED-DECIMAL clause for internal decimal items. Such items appear in storage in packed decimal format. There are 2 digits for each character position, except for the trailing character position, which is occupied by the low-order digit and the sign. Such an item may contain any of the digits 0 through 9, plus a sign, representing a value not exceeding 18 decimal digits.

Computational

Specify the COMPUTATIONAL phrase for internal decimal items. Such an item appears in storage as 2 digits per byte, with the sign contained in the 4 rightmost bits of the rightmost byte. An internal decimal item can contain any of the digits 0 through 9 plus a sign. If the PICTURE of an internal decimal item does not contain an S, the sign is occupied by a bit configuration that is interpreted as positive.

COMP-3 or COMPUTATIONAL-3

COMPUTATIONAL-3 or COMP-3 (internal decimal) is the equivalent of PACKED-DECIMAL.

COMP-4 COMPUTATIONAL-4

COMPUTATIONAL-4 or COMP-4 (binary) is the equivalent of BINARY.

DISPLAY

DISPLAY specifies that the data item is stored in character form, 1 character for each 8-bit byte. USAGE IS DISPLAY is valid for items that are:

INDEX

A data item defined with the INDEX phrase is an index data item.

An index data item is a 4-byte elementary item (not necessarily connected with any table) that you can use to save index-name values for future reference. You can use the SET statement to assign an index-name value to an index data item.

POINTER

A data item defined with the POINTER phrase is a pointer data item.

A pointer data item is a 4-byte elementary item that may be used to accomplish limited base addressing. Pointer data items may be compared for equality or moved to other pointer data items.

You may only use a pointer data item:

The POINTER phrase may be specified for data items with any level number except level 88.

VALUE Clause

Description
The VALUE clause specifies the initial contents of a data item or the value or values associated with a condition-name. The VALUE clause has three formats:

Literal VALUE Clause

Description
The Literal VALUE Clause specifies the initial value of a data item.

If the item is numeric, all VALUE clause literals must be numeric.

All numeric literals in a VALUE clause of an item must have a value that is within the range of values indicated by the PICTURE clause for that item.

If the item is an elementary or group alphabetic, alphanumeric, alphanumeric-edited, or numeric-edited item, the VALUE clause literal must be nonnumeric.

If the item is Boolean, the VALUE clause must be a Boolean literal.

Literal VALUE Clause
 
->->---VALUE--*----*--literal---------------------------------><-
            *-IS-*

Condition-Name VALUE Clause -- Level-88 Entry

Description
The Condition-Name VALUE Clause associates a single value, multiple values, and/or ranges of values with a condition-name. Each such condition-name requires a separate level-88 entry.
Condition-Name VALUE Clause (Level-88 Entry)
 
->->---88 condition-name--*-VALUE--*----*---*------------------>
                        +        *-IS-*   +
                        *-VALUES-*-----*--*
                                 *-ARE-*
 
     *-------------------------------------*
     V                                     +
->----literal-1----*------------------------*--.-----------><-
                  **-THROUGH-*--literal-2--*
                   *-THRU----*

condition-name

A condition-name is a user-specified name that associates a single value, multiple values, and/or ranges of values with a conditional variable.

A conditional variable is a data item that can assume one or more values that can in turn be associated with a condition-name.

literal-1

When you specify literal-1 alone, the condition-name is associated with a single value.

literal-2

When you specify THROUGH literal-2, the condition-name is associated with at least one range of values, and literal-1 must be less than literal-2.

NULL Value Clause

Description
The Data Description Entry Format 3 (NULL Value Clause) assigns an address that is not valid to a pointer data item (an item defined as USAGE IS POINTER). The value of NULL is an undefined value.

You can specify VALUE IS NULL only for elementary items that are described implicitly or explicitly as USAGE IS POINTER.

NULL Value Clause
 
->->---VALUE*--*-*--NULL---*----><-
          *IS* *--NULLS--*


[ Top of Page | Previous Page | Next Page | Table of Contents ]