Enterprise COBOL for z/OS, V4.2, Language Reference

INITIALIZE statement

The INITIALIZE statement sets selected categories of data fields to predetermined values. It is functionally equivalent to one or more MOVE statements.

Read syntax diagramSkip visual syntax diagram
Format

               .--------------.   
               V              |   
>>-INITIALIZE----identifier-1-+--------------------------------->

>--+------------------------------------------------------------------------+-><
   |            .---------------------------------------------------------. |   
   |            V                                                         | |   
   '-REPLACING----+-ALPHABETIC----------+--+------+--BY--+-identifier-2-+-+-'   
                  +-ALPHANUMERIC--------+  '-DATA-'      '-literal-1----'       
                  +-ALPHANUMERIC-EDITED-+                                       
                  +-NATIONAL------------+                                       
                  +-NATIONAL-EDITED-----+                                       
                  +-NUMERIC-------------+                                       
                  +-NUMERIC-EDITED------+                                       
                  +-DBCS----------------+                                       
                  '-EGCS----------------'                                       

identifier-1
Receiving areas.

identifier-1 must reference one of the following:

  • An alphanumeric group item
  • A national group item
  • An elementary data item of one of the following categories:
    • Alphabetic
    • Alphanumeric
    • Alphanumeric-edited
    • DBCS
    • External floating-point
    • Internal floating-point
    • National
    • National-edited
    • Numeric
    • Numeric-edited
  • A special register that is valid as a receiving operand in a MOVE statement with identifer-2 or literal-1 as the sending operand.

When identifier-1 references a national group item, identifier-1 is processed as a group item.

identifier-2, literal-1
Sending areas.

When identifier-2 references a national group item, identifier-2 is processed as an elementary data item of category national.

identifier-2 must reference an elementary data item (or a national group item treated as elementary) that is valid as a sending operand in a MOVE statement with identifier-1 as the receiving operand.

literal-1 must be a literal that is valid as a sending operand in a MOVE statement with identifier-1 as the receiving operand.

A subscripted item can be specified for identifier-1. A complete table can be initialized only by specifying identifier-1 as a group that contains the complete table.

Usage note: The data description entry for identifier-1 can contain the DEPENDING phrase of the OCCURS clause. However, you cannot use the INITIALIZE statement to initialize a variably-located item or a variable-length item.

The data description entry for identifier-1 must not contain a RENAMES clause.

Special registers can be specified for identifier-1 and identifier-2 only if they are valid receiving fields or sending fields, respectively, for the implied MOVE statements.

REPLACING phrase

When the REPLACING phrase is specified:

  • identifier-2 must reference an item of a category that is valid as a sending operand in a MOVE statement to an item of the corresponding category specified in the REPLACING phrase.
  • literal-1 must be of a category that is valid as a sending operand in a MOVE statement to an item of the corresponding category specified in the REPLACING phrase.
  • A floating-point literal, a data item of category internal floating-point, or a data item of category external floating point is treated as if it were in the NUMERIC category.
  • The same category cannot be repeated in a REPLACING phrase.

The keyword following the word REPLACING corresponds to a category of data shown in Classes and categories of data.

When the REPLACING phrase is not specified:

  • SPACE is the implied sending item for receiving items of category alphabetic, alphanumeric, alphanumeric-edited, DBCS, national, or national-edited.
  • ZERO is the implied sending item for receiving items of category numeric or numeric-edited.

INITIALIZE statement rules

  1. Whether identifier-1 references an elementary item, an alphanumeric group item, or a national group item, all operations are performed as if a series of MOVE statements had been written, each of which had an elementary item as a receiving field.

    If the REPLACING phrase is specified:

    • If identifier-1 references an alphanumeric group item or a national group item, any elementary item within the data item referenced by identifier-1 is initialized only if it belongs to a category specified in the REPLACING phrase.

    Initialization takes place as if the data item referenced by identifier-2 or literal-1 were the sending operand in an implicit MOVE statement to the receiving item.

    All elementary receiving fields, including all occurrences of table items within the group, are initialized, with the following exceptions:

    • Index data items
    • Object references
    • Data items defined with USAGE IS POINTER, USAGE IS FUNCTION-POINTER, or USAGE IS PROCEDURE-POINTER
    • Elementary FILLER data items
    • Items that are subordinate to identifier-1 and contain a REDEFINES clause, or any items subordinate to such an item. (However, identifier-1 can contain a REDEFINES clause or be subordinate to a redefining item.)
  2. The areas referenced by identifier-1 are initialized in the order (left to right) of the appearance of identifier-1 in the statement. Within a group receiving field, affected elementary items are initialized in the order of their definition within the group.
  3. If identifier-1 occupies the same storage area as identifier-2, the result of the execution of this statement is undefined, even if these operands are defined by the same data description entry.


Rate this page

[ Index | Table of contents ]