The VALUE Clause

General Formats for Format 1


*

General Formats for Format 2


*
MF 

General Formats for Format 3


*
ISO2002MF 

General Formats for Format 4


*

General Formats for Format 5

NET 
*

Syntax Rules for All Formats

  1. If a signed numeric literal is specified, the subject of the entry must be a signed numeric data item.
  2. If the category of the subject of the entry is numeric, all literals in the VALUE clause must be numeric and have a value that is within the range of values indicated by the PICTURE clause or the USAGE clause. If the usage is other than float-short or float-long this value must not require truncation of non-zero digits. This value must have the digit zero in each position that corresponds to a picture character symbol 'P'.
  3. If the item is of class alphabetic or alphanumeric, literals in the VALUE clause must be alphanumeric literals. Alphanumeric literals in the VALUE clause of an elementary item must not exceed the size indicated by an explicit PICTURE clause. Alphanumeric literals in the VALUE clause of an alphanumeric group item must not exceed the size of the group item.
  4. If the item is of class national, literals in the VALUE clause must be national literals. National literals in the VALUE clause of an elementary item must not exceed the size indicated by an explicit PICTURE clause. National literals in the VALUE clause of a national group item must not exceed the size of the group item.

Syntax Rules for Formats 1 and 4

  1. The VALUE clause must not be specified in a data description entry that contains a REDEFINES clause or in an entry that is subordinate to an entry containing a REDEFINES clause.
  2. If the VALUE clause is specified at the group level, the literal must be of the same category as the group item or must be a figurative constant that is permitted in a MOVE statement to a receiving item of that category. The VALUE clause cannot be specified at subordinate levels within this group.
  3. If a VALUE clause is specified at the group level, subordinate items within that group must not be described with a JUSTIFIED or SYNCHRONIZED clause, and all data items subordinate to an alphanumeric group item must be explicitly or implicitly described with USAGE DISPLAY.

Syntax Rules for Format 1

  1. OSVS VALUES ARE can be used with Format 1.
  2. OSVSVSC2MF The VALUE clause may not be used with external floating-point data items.

    MF The VALUE clause may be used with external floating-point data items.

  3. OSVSVSC2MF The VALUE clause may be used for an internal floating-point data item, that is an item defined with USAGE COMP-1 or USAGE COMP-2. In this case literal-1 must either be a floating-point literal, the figurative constant ZERO, or a numeric literal representing the value zero.

Syntax Rules for Format 2

  1. The words THRU and THROUGH are equivalent.
  2. Any number of Format 2 entries can be written for a data item.
  3. Format 2 must be used only in connection with a condition-name.
  4. In a condition-name entry, the VALUE clause is required. The VALUE clause and the condition-name itself are the only two clauses permitted in the entry.
  5. Literal-2 must be less than literal-3.
  6. OSVSVSC2MF Format 2 may be used to define a conditional-variable associated with an internal floating-point data item, but not an external floating-point data item. In this case, literal-2 and literal-3 must be floating-point literals, the figurative constant ZERO, or numeric literals representing the value zero.

    MF Format 2 may be used to define a condition-variable associated with an external floating-point data item.

  7. ISO2002MF Literal-4 must not be equal to any literal-2, and in any literal-2 THROUGH literal-3 pair, literal-4 cannot be greater than or equal to literal-2 and less than or equal to literal-3.
MF 

Syntax Rules for Format 3

  1. MF All identifiers must have been defined before the declaration of the level 78 item. If either identifier-1 or identifier-3 (LENGTH parameters) is a group item, the definition of that group must have been completed before the level 78 declaration, by the appearance of another data item at the same or lower level number.
ISO2002MF 

Syntax Rules for Format 4

  1. ISO2002MF In Format 4 (level 78) the VALUE clause may be omitted if the item is specified in an ENUM definition.
  2. ISO2002MF A data description entry that contains the VALUE clause must contain an OCCURS clause or be subordinate to a data description entry that contains an OCCURS clause.
  3. ISO2002MF Subscript-1 and subscript-2 must be integer numeric literals.
  4. ISO2002MF In one FROM phrase, there must be one subscript-1 specified for each OCCURS clause for the subject of the entry or superordinate to that entry, specified in the same order as a subscripted reference to the subject of the entry would be specified. Each instance of subscript-1 must not exceed the maximum number of occurrences specified in the OCCURS clause associated with that instance.
  5. ISO2002MF If the TO phrase is specified, there must be one subscript-2 specified for each OCCURS clause for the subject of the entry or superordinate to that entry, specified in the same order as a subscripted reference to the subject of the entry would be specified. Each instance of subscript-2 must not exceed the maximum number of occurrences specified in the OCCURS clause associated with that instance. The specification of subscript-2 in one TO phrase must be such that the table element associated with subscript-2 is the same occurrence or a successive occurrence of the table element associated with the corresponding subscript-1.
NET 

Syntax Rules for Format 5

  1. NET Format 5 must be used only in conjunction with USAGE CONDITION-VALUE.

General Rules for Formats 1, 2 and 4

  1. The VALUE clause must not conflict with other clauses in the data description of the item or in the data description within the hierarchy of the item. The following rules apply:
    1. If the literal defines the value of a data item, the literal is aligned in the data item according to the standard alignment rules. (See the topic Standard Alignment Rules in the chapter Concepts of the COBOL Language.)
    2. If the category of the item is alphabetic, alphanumeric, alphanumeric edited or numeric edited all literals in the VALUE clause must be nonnumeric. The literal is aligned in the data item as if the data item had been described as alphanumeric. (See the topic Standard Alignment Rules in the chapter Concepts of the COBOL Language.) Editing characters in the PICTURE clause are included in determining the size of the data item (see the topic The PICTURE Clause) but have no effect on initialization of the data item. Therefore, the programmer is responsible for specifying the value of a literal associated with an edited data item in edited form.

      MF If the item is numeric edited, the value can be a numeric literal or a nonnumeric literal. If the value is a numeric literal, the value contained in the item will be the same as if the numeric literal were moved to the numeric edited item.

    3. Initialization takes place independent of any BLANK WHEN ZERO or JUSTIFIED clause that can be specified.

General Rules for Data-Item (Format 1)

  1. Rules governing the use of the VALUE clause in data item entries differ with the respective sections of the Data Division:
    1. In the Working-Storage Section

      ISO2002MF and Local-Storage Section,

      the VALUE clause can be used to specify the initial value of a data item, in which case the clause causes the item to assume the specified value at the time the runtime element is placed into its initial state. If the VALUE clause is not used in an item's description, the initial value of that data item is undefined.

    2. In the File Section and the Linkage Section,

      OS390 and Local-Storage Section,

      the VALUE clause can be used in data item entries, but it takes effect only when an INITIALIZE statement that applies to the entries is executed.

  2. OSVSVSC2MF 
  3. If the VALUE clause is specified in an entry at the group level the group area is initialized without consideration for the individual elementary or group items contained within this group.
  4. VSC2MF  The figurative constant NULL can be specified in the VALUE clause only if the data item is defined with USAGE POINTER or USAGE PROCEDURE-POINTER. This is the only value you can specify in the VALUE clause for such an item. The effect is to set the pointer in such a way that it is guaranteed not to point to any data item.
  5. ANS85 A VALUE clause specified in a data description entry that contains an OCCURS clause, or in an entry that is subordinate to an OCCURS clause, causes every occurrence of the associated data item to be assigned the specified value.
  6. ANS85 If a VALUE clause is specified in a data description entry of a data item which is associated with a variable occurrence data item, the initialization of the data item behaves as if the value of the data item referenced by the DEPENDING ON phrase in the OCCURS clause specified for the variable occurrence data item is set to the maximum number of occurrences as specified by that OCCURS clause. A data item is associated with a variable occurrence data item in any of the following cases:
    1. It is a group data item which contains a variable occurrence data item.
    2. It is a variable occurrence data item.
    3. It is a data item that is subordinate to a variable occurrence data item.

    If a VALUE clause is associated with the data item referenced by a DEPENDING ON phrase, that value is considered to be placed in the data item after the variable occurrence data item is initialized.

  7. ISO2002 A data item of class object is initialized to null. The initial value takes effect when VALUE clauses take effect and when storage for the data item is allocated.
  8. ISO2002 A data item of class pointer is initialized to null. The initial value takes effect when VALUE clauses take effect and when storage for the data item is allocated.

Condition-name Rules (Format 2)

  1. In a condition-name entry, the VALUE clause is required. The VALUE clause and the condition-name itself are the only two clauses permitted in the entry. The characteristics of a condition-name are implicitly those of its conditional variable.
  2. Format 2 can be used only in connection with condition-names. Wherever the THRU phrase is used, literal-2 must be less than literal-3.
  3. The FALSE phrase is meaningful only if the associated condition-name is referenced in a SET condition-name TO FALSE statement. (See the topic The SET Statement.)

Constant-Name Rules (Format 3)

  1. MF Format 3 can be used only in a constant-name entry.
  2. MF If literal-5 is specified and not followed by an operator, the characteristic of the constant-name is that of literal-5. Otherwise, the characteristic of the constant-name is that of an integer.
  3. MF  Any number of arithmetic or logical operators can be used. The result is evaluated using integer arithmetic in strict left to right order. No parentheses can be used. If any intermediate result is less than zero, the final value is undefined. A constant-name may be used in place of integer-1.
  4. MF The logical operations AND and OR act on the binary representation in a bit-wise manner.
  5. MF LENGTH of identifier-1 or identifier-3 is the size of the storage allocated for identifier-1 or identifier-3, respectively. If the identifier is a group item, the length includes all subordinate data items.
  6. MF The value returned by NEXT is the offset at which the next byte of storage occurs after the previous data declaration. (It is not the offset of the start of the next data declaration.) If that data declaration was of a table defined with an OCCURS clause, the value returned by NEXT is the offset at which the next byte of storage occurs after the first element of the table.
  7. MF START of identifier-2 or identifier-4 is the offset at which identifier-2 or identifier-4, respectively, begins.
  8. MF For rules 18 and 19, the offset is defined as follows:
    • If the identifier is part of an EXTERNAL record or a LINKAGE record, the offset is calculated from the start of the associated 01-level;
    • If the identifier is defined in the Local-Storage Section, the offset is calculated from the start of the Local-Storage Section;
    • Otherwise the offset is calculated from the start of the Data Division.
  9. MF Offsets are not portable across different COBOL implementations and no reliance should be placed on particular values outside this compilation unit.

Table Rules (Format 4)

  1. ISO2002MF A format 2 VALUE clause initializes a table element to the value of literal-6. The table element initialized is identified by subscript-1. Consecutive table elements are initialized, in turn, to the value of successive occurrences of literal-6. Consecutive table elements are referenced by incrementing by 1 the subscript that represents the least inclusive dimension of the table. When any reference to a subscript, prior to incrementing it, is equal to the maximum number of occurrences specified by its corresponding OCCURS clause, that subscript is set to 1 and the subscript for the next most inclusive dimension of the table is incremented by 1.
  2. ISO2002MF If the TO phrase is specified, all occurrences of literal-6 are reused, in the order specified, as a source during the initialization described in the immediately preceding rule. This repetition is done until the table element identified by subscript-2 is initialized.
  3. ISO2002MF If the TO phrase is not specified, it is as if the TO phrase were specified with each subscript-2 as the maximum number of occurrences of the table associated with each corresponding subscript-1.
  4. ISO2002MF If multiple specifications of the FROM phrase reference the same table element, the value defined by the last specified FROM phrase in the VALUE clause is assigned to the table element.
NET 

Format 5

  1. NET If the TRUE phrase is specified, the associated condition-value data item is set to true. If the FALSE phrase is specified, the associated condition-value data item is set to false.

Examples

  1. An example of using the NEXT phrase of the VALUE clause is provided in the section NEXT Phrase of CONSTANT-NAMES.