I have a query regarding INITIALIZing REDEFINED variable.
I've below code in the program which redefines WS-A with WS-B. And WS-B is INITIALIZEd later in the program.
01 WS-A.
05 WS-A-OUTLINE.
10 WS-A-SYSTEM-ID PIC X(02).
10 WS-A-SUBSYS-ID PIC X(04).
10 WS-A-TYPE PIC X(01).
88 WS-A-TYPE-OK VALUE "O", "B".
88 WS-A-ONLINE VALUE "O".
88 WS-A-BATCH VALUE "B".
05 WS-A-INLINE.
10 WS-A-RC PIC X(02).
88 WS-A-DATA VALUE SPACE, "20".
88 WS-A-ERROR VALUE "10", "90".
05 WS-REST PIC X(<remaining>). <-- P.S: I've omitted declaration of rest of the variables as it'd be lengthier.
01 WS-B REDEFINES WS-A.
05 FILLER PIC X(400).
.
.
.
.
.
INITIALIZE WS-B.
.
.
.
05 WS-A-OUTLINE.
10 WS-A-SYSTEM-ID PIC X(02).
10 WS-A-SUBSYS-ID PIC X(04).
10 WS-A-TYPE PIC X(01).
88 WS-A-TYPE-OK VALUE "O", "B".
88 WS-A-ONLINE VALUE "O".
88 WS-A-BATCH VALUE "B".
05 WS-A-INLINE.
10 WS-A-RC PIC X(02).
88 WS-A-DATA VALUE SPACE, "20".
88 WS-A-ERROR VALUE "10", "90".
05 WS-REST PIC X(<remaining>). <-- P.S: I've omitted declaration of rest of the variables as it'd be lengthier.
01 WS-B REDEFINES WS-A.
05 FILLER PIC X(400).
.
.
.
.
.
INITIALIZE WS-B.
.
.
.
But while compiling this program in COBOL 4.2, I'm getting no warnings. However, in COBOL 6.2, I'm getting below warning.
IGYPS2047-W "INITIALIZE" statement operand "WS-B" did not meet conditions for initialization.
"WS-B" was not initialized.
I think it is because COBOL 6.2 will not allow to INITIALIZE a redefined variable (WS-B).
So in that case, will I be able to achieve same by INITIALIZing WS-A instead of WS-B?
Thanks.