COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Example 104 INITIALIZE Statements
INITIALIZE UNSTRING-COUNTERS
INSPECT-COUNTERS
REPLACING NUMERIC DATA BY ZERO
INITIALIZE UNSTRING-POINTERS
INSPECT-POINTERS
REPLACING NUMERIC DATA BY 1
The INITIALIZE statement in Example 105 assigns a value of zero to only the numeric-edited items
in a table composed of a variety of categories.
Example 105 INITIALIZE Statement
01 STOCK.
03 STOCK-ITEM OCCURS 500 TIMES.
05 S-NAME PIC X(30).
05 S-WHOLESALE-PRICE PIC $$$,$$$.99.
05 S-MARKUP-PCT PIC P999.
...
INITIALIZE STOCK
REPLACING NUMERIC-EDITED DATA BY ZERO
Usage Considerations:
Execution of the INITIALIZE Statement
The INITIALIZE statement is equivalent to a series of MOVE statements, each of which has an
elementary item as its receiving operand.
Determining the Receiving Operands
If receiver includes reference modification, the data item to which it refers is handled as
an elementary item.
If receiver references an elementary data item, that data item is a receiving operand unless
the INITIALIZE statement includes a REPLACING phrase and the category of the elementary
data item is not specified in any of the phrases following the REPLACING phrase. If receiver
references an elementary data item that is not a receiving operand, that data item is not
initialized.
If receiver references a data structure, each elementary item subordinate to the data structure
(including each element in a subordinate table) is a receiving operand; however, the initialize
operation ignores:
Index or pointer data items
Elementary FILLER data items
Data items whose descriptions contain REDEFINES clauses
Data items subordinate to data items whose descriptions contain REDEFINES clauses
Data items that are not in the same categories as the initial values specified for them; for
example, an ALPHABETIC receiver is not initialized to a NUMERIC replacement
value even if the INITIALIZE statement specifies this
344 Procedure Division Verbs