Format 1
Format 1 specifies the initial value of a data item. Initialization is independent of any BLANK WHEN ZERO or JUSTIFIED clause that is specified.
A format-1 VALUE clause specified in a data description entry that contains or is subordinate to an OCCURS clause causes every occurrence of the associated data item to be assigned the specified value. Each structure that contains the DEPENDING ON phrase of the OCCURS clause is assumed to contain the maximum number of occurrences for the purposes of VALUE initialization.
The VALUE clause must not be specified for a data description entry that contains or is subordinate to an entry that contains either an EXTERNAL or a REDEFINES clause. This rule does not apply to condition-name entries.
A format-1 VALUE clause can be specified for an elementary data item or for a group item. When the VALUE clause is specified at the group level, the group area is initialized without consideration for the subordinate entries within the group. In addition, a VALUE clause must not be specified for subordinate entries within the group.
For group items, the VALUE clause must not be specified if any subordinate entries contain a JUSTIFIED or SYNCHRONIZED clause.
If the VALUE clause is specified for an alphanumeric group, all subordinate items must be explicitly or implicitly described with USAGE DISPLAY.
The VALUE clause must not conflict with other clauses in the data description entry or in the data description of that entry's hierarchy.
The functions of the editing characters in a PICTURE clause are ignored in determining the initial value of the item described. However, editing characters are included in determining the size of the item. Therefore, any editing characters must be included in the literal. For example, if the item is defined as PICTURE +999.99 and the value is to be +12.34, then the VALUE clause should be specified as VALUE "+012.34".
A VALUE clause cannot be specified for external floating-point items.
A data item cannot contain a VALUE clause if the prior data item contains an OCCURS clause with the DEPENDING ON phrase.
Rules for literal values
- Wherever a literal is specified, a figurative constant can be substituted, in accordance with the rules specified in Figurative constants.
- If the item is class numeric, the VALUE clause literal must be numeric. If the literal defines the value of a WORKING-STORAGE item or LOCAL-STORAGE item, the literal is aligned according to the rules for numeric moves, with one additional restriction: The literal must not have a value that requires truncation of nonzero digits. If the literal is signed, the associated PICTURE character-string must contain a sign symbol.
- With some exceptions, numeric literals in a VALUE clause must
have a value within the range of values indicated by the PICTURE clause
for the item. For example, for PICTURE 99PPP, the literal must be
zero or within the range 1000 through 99000. For PICTURE PPP99, the
literal must be within the range 0.00000 through 0.00099.
The exceptions are the following ones:
- Data items described with usage COMP-5 that do not have a picture symbol P in their PICTURE clause.
- When the TRUNC(BIN) compiler option is in effect, data items described
with usage BINARY, COMP, or COMP-4 that do not have a picture symbol
P in their PICTURE clause.
A VALUE clause for these items can have a value up to the capacity of the native binary representation.
- If the VALUE clause is specified for an elementary alphabetic, alphanumeric, alphanumeric-edited, or numeric-edited item described with usage DISPLAY, the VALUE clause literal must be an alphanumeric literal or a figurative constant. The literal is aligned according to the alphanumeric alignment rules, with one additional restriction: the number of characters in the literal must not exceed the size of the item.
- If the VALUE clause is specified for an elementary national, national-edited, or numeric-edited item described with usage NATIONAL, the VALUE clause literal must be a national or alphanumeric literal or a figurative constant as specified in Figurative constants. The value of an alphanumeric literal is converted from its source code representation to UTF-16 representation. The literal is aligned according to the national alignment rules, with one additional restriction: the number of characters in the literal must not exceed the size, in character positions, of the item.
- If the VALUE clause is specified for an elementary UTF-8 item, the VALUE clause literal must be a UTF-8 or an alphanumeric literal or a figurative constant as specified in Figurative constants. The value of an alphanumeric or national literal is converted from its source code representation to UTF-8 representation. The literal is aligned according to the UTF-8 alignment rules, with one additional restriction: if the UTF-8 item is a fixed character-length UTF-8 item (i.e., it was not defined with the BYTE-LENGTH phrase of the PICTURE clause or the DYNAMIC LENGTH clause), then the number of characters in the literal must not exceed the size, in character positions, of the item. Otherwise, the number of bytes of the literal must not exceed the maximum byte length allowed by the item.
- If the VALUE clause is specified at the group level for an alphanumeric group, the literal must be an alphanumeric literal or a figurative constant as specified in Figurative constants, other than ALL national-literal or ALL utf-8-literal. The size of the literal must not exceed the size of the group item.
- If the VALUE clause is specified at the group level for a national group, the literal can be an alphanumeric literal, a national literal, or one of the figurative constants ZERO, SPACE, QUOTES, HIGH-VALUE, LOW-VALUE, symbolic character, ALL national-literal, or ALL -literal. The value of an alphanumeric literal is converted from its source code representation to UTF-16 representation. Each figurative constant represents a national character value. The size of the literal must not exceed the size of the group item.
- If the VALUE clause is specified at the group level for a UTF-8 group, the literal can be an alphanumeric literal, a UTF-8 literal, or one of the figurative constants ZERO, SPACE, QUOTES, HIGH-VALUE, LOW-VALUE, symbolic character, ALL utf-8-literal, or ALL -literal. The value of an alphanumeric literal is converted from its source code representation to UTF-8 representation. Each figurative constant represents a UTF-8 character value. The size of the literal must not exceed the size of the group item.
- A VALUE clause associated with a DBCS item must contain a DBCS literal, the figurative constant SPACE, or the figurative constant ALL DBCS-literal. The length of the literal must not exceed the size indicated by the data item's PICTURE clause.
- A VALUE clause that specifies a national literal can be associated only with a data item of class national.
- A VALUE clause that specifies a UTF-8 literal can be associated only with a data item of class UTF-8.
- A VALUE clause that specifies a DBCS literal can be associated only with a data item of class DBCS.
- A VALUE clause associated with a COMPUTATIONAL-1 or COMPUTATIONAL-2
(internal floating-point) item must specify a floating-point literal.
In addition, the figurative constant ZERO and both integer and decimal
forms of the zero literal can be specified in a floating-point VALUE
clause.
You cannot specify a floating-point format numeric literal in the VALUE clause of a fixed-point numeric item.
For information about floating-point literal values, see Rules for floating-point literal values.
Example
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-A PIC 9(2)V9 VALUE 5.6.
01 WS-B PIC A(15) VALUE 'Hello world'.
01 WS-C PIC 99 VALUE ZERO.
PROCEDURE DIVISION.
DISPLAY "WS-A: " WS-A.
DISPLAY "WS-B: " WS-B.
DISPLAY "WS-C: " WS-C.
STOP RUN.
The output is as follows:WS-A: 5.6
WS-B: Hello world
WS-C: 0