Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Redifine question

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
dilpreet

New User


Joined: 18 Mar 2008
Posts: 34
Location: INDIA

PostPosted: Thu Nov 26, 2009 5:39 pm    Post subject: Redifine question
Reply with quote

Was asked that

01 a pic x(4)
01 b redifine a pic 9(4)

move 'ABCD' to a
display b


What would be the display

Answered:
some value other than ABCD will be displayed but it wont abend the program.

Please clear the doubt!!!!
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Thu Nov 26, 2009 6:27 pm    Post subject:
Reply with quote

The actual answer is that ABCD will be displayed. The REDEFINE doesn't change the value of the variable, and PIC 9(04) displays the same as PIC X(04).
Back to top
View user's profile Send private message
zh_lad

Active User


Joined: 06 Jun 2009
Posts: 101
Location: UK

PostPosted: Wed Mar 24, 2010 3:14 pm    Post subject: Reply to: Redifine question
Reply with quote

How about redefining as COMP-3?
05 WS-A PIC X(5) VALUE 'ABCDE'.
05 WS-B REDEFINES WS-A PIC S9(5) COMP-3.
05 WS-C PIC 9(5).
05 WS-D PIC X(5).
05 WS-E REDEFINES WS-D PIC 9(5).

Display shows following values:
WS-A = ABCDE
4EE6C474CCCCC
062010E012345
----------------------------------
WS-B = Ü1Ü2Ü
4EE6C474FFFFF
062020E0C1C2C
************************************************
MOVE WS-A TO WS-C
Why does WS-C does not show 'ABCDE'? Why deos it show following? How is it different from REDEFINE?
-------------
WS-C = ABCD5
4EE6C474CCCCF
062030E012345

************************************************

I have tested redfine as numeric and it shows 'ABCDE'
MOVE 'ABCDE' TO WS-D
WS-D = ABCDE
4EE6C474CCCCC
062040E012345
-------------
WS-E = ABCDE
4EE6C474CCCCC
062050E012345

It would be great if you could clear the doubt.

Many thanks!
Back to top
View user's profile Send private message
Asif Bhatkar

New User


Joined: 21 Dec 2009
Posts: 5
Location: India

PostPosted: Wed Mar 24, 2010 3:42 pm    Post subject:
Reply with quote

I too faced this type of situation when testing for alphanumeric to numeric moves, but not able to find exact reason.
When the variable is alphanumeric the internal representation is C1 to C5 (A to E), but when we move it to numeric variable it changes the last characters internal representation to F5 (from C5). I think it may be due to the sign which is stored in the left half of LSB (For default DISPLAY format)
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Wed Mar 24, 2010 5:03 pm    Post subject:
Reply with quote

Click on the manuals link at the top of the page, find the COBOL Language Reference and Programming Guide manuals, and read them to find out what the internal formats for data are. If you do this, you will find that a PIC S9(05) COMP-3 field actually uses THREE bytes, not five bytes so your redefine has problems from the start.

Your move of WS-A to WS-C is 5 bytes to 5 bytes and WS-C is USAGE DISPLAY, which means the move will work fine. However, COBOL will guarantee that the value is not signed and will do an OI (Or Immediate) assembler instruction against hex 'F0' for the last byte of the variable. This changes the hex 'C5' ('E') value to hex 'F5' ('5').

REDEFINES causes the two variables to occupy the exact same memory locations. It is up to the programmer to ensure that the two variables are the same length and of compatible types. USAGE DISPLAY and USAGE COMP-3 are NOT compatible and cannot be redefined on each other without causing problems.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am
No new posts Asynchronous CICS Processing Question moezbud CICS 1 Mon Mar 06, 2017 6:13 pm
No new posts CICS Question RE: Browse, Readnext an... moezbud CICS 7 Sun Mar 05, 2017 5:45 am
No new posts Fault Analyzer - listings question. egrove IBM Tools 4 Thu Aug 11, 2016 5:31 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us