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

cobol interview questions

Moderator: Moderator Group

Post Reply
User avatar
Krishna
Site Admin
Posts: 1052
Joined: Fri Jan 27, 2006 7:50 am

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

Post by Krishna » Sun Jul 19, 2009 4:13 pm

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

User avatar
Krishna
Site Admin
Posts: 1052
Joined: Fri Jan 27, 2006 7:50 am

Post by Krishna » Sun Jul 19, 2009 4:13 pm

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
DISPLAY WS-TOP-RED will show 12.

sambit_mech
Member
Posts: 9
Joined: Wed Jul 14, 2010 11:17 am
Location: India

Post by sambit_mech » Wed Jul 14, 2010 11:33 am

It will cause memory overflow giving S0c4.
"By failiing to prepare, you are preparing to fail." - Benjamin Franklin

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Wed Jul 14, 2010 1:05 pm

sambit_mech,

again you are posting erroneous information.

depending on the version of COBOL,
you will either receive a compiler error,
or the structure will be defined by the compiler at the longest length,
regardless of the order of redefines.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others