GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Mainframe  >  COBOL
Go To First  |  Previous Question  |  Next Question 
 COBOL  |  Question 68 of 162    Print  
Is it possible that the REDEFINES clause has different picture clauses compared to the one it redefined?

  
Total Answers and Comments: 9 Last Update: August 31, 2008     Asked by: unica 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Gokul
 
Hi,

It is possible.

01 WS-VAR1 PIC X(5).
01 WS-VAR2 REDEFINES WS-VAR1 PIC 9(3).
.
.

MOVE "HELLO" TO WS-VAR1.
DISPLAY WS-VAR1.
DISPLAY WS-VAR2.
.
.

will give out
HELLO
HEL


Above answer was rated as good by the following members:
chandradutt
August 05, 2006 03:57:14   #1  
Mital        

RE: Is it possible that the REDEFINES clause has diffe...
well generally it is not possible.
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
September 11, 2006 16:18:08   #2  
techie        

RE: Is it possible that the REDEFINES clause has diffe...
Yes. I believe the keyword REDEFINES is meant to define a new field with picture clause different from the old one. That is:1. The new field's length maybe greater than or less than the field being redefined:05 COMPANY-NAME PIC X(20).05 COMPANY-SHORT-NAME REDEFINES COMPANY-NAME PIC X(12).2. The new field's type is different from the field being redefined:05 REPORT-DATE PIC X(8).05 REPORT-DATE-N REDEFINES REPORT-DATE PIC 9(8).Hope this clarifies.
 
Is this answer useful? Yes | No
September 25, 2006 03:03:39   #3  
Kavitha        

RE: Is it possible that the REDEFINES clause has diffe...
Yes it is possible only when the pic clause of variable to be redefined is less than or equal to the original variable.
 
Is this answer useful? Yes | No
December 19, 2006 09:06:32   #4  
AJAY        

Of cos its possible...
REDEFINES..... the word itself suggests tat u r redifining. u can tredefine it as per ur requirement. u can even redefine x( ) into 9( ) by followin t MOVE guidelines....... Regards AJAY
 
Is this answer useful? Yes | No
February 22, 2007 15:02:15   #5  
Rohit        

RE: Is it possible that the REDEFINES clause has diffe...

You can redifne with any other pic class and there is no limitation that it pc clause be greater then or equal to you can redifne a PIC X(10) with PIC X(20).


 
Is this answer useful? Yes | No
June 25, 2007 08:03:46   #6  
Gokul        

RE: Is it possible that the REDEFINES clause has diffe...
Hi

It is possible.

01 WS-VAR1 PIC X(5).
01 WS-VAR2 REDEFINES WS-VAR1 PIC 9(3).
.
.

MOVE "HELLO" TO WS-VAR1.
DISPLAY WS-VAR1.
DISPLAY WS-VAR2.
.
.

will give out
HELLO
HEL

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
August 26, 2007 06:44:23   #7  
sreenigacc        

RE: Is it possible that the REDEFINES clause has diffe...

01 ws-var1 pic x(5)

we can redefine the above variable in different ways ............
when redefining a variable both should have the same level number.........
01 ws-var2 redefines ws-var1 pic x(5)
or
01 ws-var2 redefines ws-var1 pic x(2)

or
01 ws-var2 redefines ws-var1 pic x(15)

a small example for you...........

01 ws-var1 pic x(5)
01 ws-var2 redefines ws-var1 pic x(3)

move 'abcde' to ws-var1.
display ws-var1
display ws-var2.



ws-var1 is abcde
ws-var2 is abc



move 'abc' to ws-var2.
display ws-var1
display ws-var2.



ws-var1 is abc
ws-var2 is abc



move 'abcde' to ws-var1.
move '123' to ws-var2.
display ws-var1
display ws-var2.



ws-var1 is 123
ws-var2 is 123



Thanks & Regards
Sreenivasulu G


 
Is this answer useful? Yes | No
January 08, 2008 11:31:02   #8  
lfrank Member Since: January 2008   Contribution: 9    

RE: Is it possible that the REDEFINES clause has different picture clauses compared to the one it redefined?

One of the main reasons for using a REDEFINES is to address storage areas with different picture clauses. Any field can be redefined as anything else. Having the program execute successfully with the redefined data is another matter.

The IBM COBOL Language Reference manual states the following:
"The use of a redefining data item need not be the same as that of a redefined item. This does not however cause any change in existing data. For example:
05 B PIC 99 USAGE DISPLAY VALUE 8.

05 C REDEFINES B PIC S99 USAGE BINARY.

05 A PIC S99 USAGE BINARY.

Redefining B does not change the bit configuration of the data in the storage area.


 
Is this answer useful? Yes | No
August 31, 2008 04:35:40   #9  
ragavprasanna Member Since: August 2008   Contribution: 3    

RE: Is it possible that the REDEFINES clause has different picture clauses compared to the one it redefined?
Yes it is possible redefines means using (sharing) the same memory space. It is not necessary to share variables having same picture clause.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape