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

Showing Answers 1 - 24 of 24 Answers

Mital

  • Aug 5th, 2006
 

well, generally it is not possible.

  Was this answer useful?  Yes

techie

  • Sep 11th, 2006
 

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.

  Was this answer useful?  Yes

Kavitha

  • Sep 25th, 2006
 

Yes it is possible only when the pic clause of variable to be redefined is less than or equal to the original variable.

  Was this answer useful?  Yes

AJAY

  • Dec 19th, 2006
 

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

  Was this answer useful?  Yes

Rohit

  • Feb 22nd, 2007
 

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).

  Was this answer useful?  Yes

Gokul

  • Jun 25th, 2007
 

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

sreenigacc

  • Aug 26th, 2007
 

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

  Was this answer useful?  Yes

lfrank

  • Jan 8th, 2008
 

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.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions