The INITIALIZE statement sets selected categories of data fields to predetermined values. It is functionally equivalent to one or more MOVE statements.
INITIALIZE perform no action on FILLER areas and also OCCURS DEPENDING ON clause untouched.
INITIALIZE statement do,
Syntax:
INITIALIZE identifier-1 [REPLACING {ALPHABETIC/ALPHANUMERIC/NUMERIC/ALPHANUMERIC-EDITED/NUMERIC-EDITED} DATA BY {identifier-2/literal}] |
INITIALIZE REPLACING: To move data with a specific constants instead of Zeros and spaces.
Let's see example to understand the concepts clearly,
01 WS-RECORD. 05 WS-NUMBER PIC 9(09). 05 WS-NAME PIC X(10). 05 WS-LOB PIC X(03). |
Example 1:
INITIALIZE WS-RECORD. |
This Moves zeros to WS-NUMBER and Spaces to WS-NAME and WS-LOB.
Example 2:
INITIALIZE WS-RECORD REPLACING NUMERIC DATA BY 9 ALPHANUMERIC DATA BY 'X'. |
This above statement Moves 9 TO WS-NUMBER AND X is being moved to WS-NAME and WS-LOB.
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!