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
 

 

Can I redfine 9(3) with X(5)? What is the result of below?

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

New User


Joined: 05 Sep 2006
Posts: 6

PostPosted: Tue Mar 06, 2007 10:57 am    Post subject: Can I redfine 9(3) with X(5)? What is the result of below?
Reply with quote

What would be the result of the following?

05 WS-A PIC 9(3).
05 WS-B REDEFINES WS-A PIC X(5).


Move 999 to WS-A.
Display WS-B.
Back to top
View user's profile Send private message

muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Chennai

PostPosted: Tue Mar 06, 2007 11:36 am    Post subject: Re: Can I redfine 9(3) with X(5)? What is the result of belo
Reply with quote

WS-B will have 999

Please search the forum before you make a post.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Tue Mar 06, 2007 6:38 pm    Post subject:
Reply with quote

I would expect a compile error as WS-B is longer than WS-A.
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Chennai

PostPosted: Tue Mar 06, 2007 7:38 pm    Post subject: Re: Can I redfine 9(3) with X(5)? What is the result of belo
Reply with quote

Phil,
I tried it out and i got the value 999 moved to WS-B.

REDEFINING the varaible longer or shorter will not give a compiler error.It is possible for truncation of data if the redefined variable is shorter.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Wed Mar 07, 2007 6:54 pm    Post subject:
Reply with quote

I see I was wrong about the compiler error.

However, notwithstanding the lack of a compile warning/error, you really don't want the redefining variable to be longer.

Above, the actual value of WS-B is:
bytes 1-3 = '999'
bytes 4-5 = x'00'

Here's the hex display:
999
FFF00
99900

This test:

IF WS-B = '999'
DISPLAY 'EQUALS 999'
ELSE
DISPLAY 'NOT EQUALS 999'
END-IF.

produces this output:

NOT EQUALS 999

because the compare of '999' against the X(5) field is trying to match '999' blank-blank.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Mar 07, 2007 8:20 pm    Post subject: Re: Can I redfine 9(3) with X(5)? What is the result of belo
Reply with quote

muthuvel wrote:
I tried it out and i got the value 999 moved to WS-B.
No, not quite, if you had done a display '*' WS-B '*' you would have seen "*999??* where the ? is whatever was previously in WS-B.
Quote:
REDEFINING the variable longer or shorter will not give a compiler error.It is possible for truncation of data if the redefined variable is shorter.
No, not quite, it is more dependent upon the compiler. Either way you will never get truncation; if the compiler can't handle it, it will fail compile; if the compiler can handle it, it will reserve the extra space after the redefined data to cover for the longer redefining data.
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Chennai

PostPosted: Thu Mar 08, 2007 9:01 pm    Post subject: Re: Can I redfine 9(3) with X(5)? What is the result of belo
Reply with quote

Phil and William,
Thanks icon_rolleyes.gif
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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts scheduling between OPC and TWS give u... nsbl IBM Tools 4 Sun Mar 12, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
This topic is locked: you cannot edit posts or make replies. How to run and see the result of DFH$... lind sh CICS 2 Wed Jul 27, 2016 7:04 pm
No new posts Build record according subtraction re... witsche SYNCSORT 5 Fri Oct 02, 2015 12:53 pm


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