Interview Questions

Can I redefine an X(100) field with a field of X(200)?

COBOL Interview Questions


(Continued from previous question...)

Can I redefine an X(100) field with a field of X(200)?

Yes. redefines just causes both fields to start at the same location. For example:
01 WS-TOP PIC X(1)
01 WS-TOP-RED REDEFINES WS-TOP PIC X(2).
If you MOVE "12" to WS-TOP-RED,
DISPLAY WS-TOP will show 1 while
01 WS-TOP-RED will show 12.

(Continued on next question...)

Other Interview Questions