Page 1 of 1

Redefines: What is var1/ var2 ?

PostPosted: Thu Nov 08, 2007 1:23 am
by abkumarch
01 ws-data
05 var1 pic X(05)
05 var2 REDEFINES var1 pic 9(5)


p.d.
MOVE 'abcde' TO var1
NOW what is the value of var1 & var2 ?

Re: Redefines: What is var1/ var2 ?

PostPosted: Thu Nov 08, 2007 2:07 am
by dick scherrer
Hello,

What happens when you try this?

Re: Redefines: What is var1/ var2 ?

PostPosted: Thu Nov 08, 2007 3:53 am
by CICS Guy
abkumarch wrote:NOW what is the value of var1 & var2 ?
Quite simple, var1 will contain 'abcde' and so will var2....
But, var2 will be kinda garbagey and could result in anything from '12345' to ASRA/S0C7, depending upon how it gets used/referenced.....

Re: Redefines: What is var1/ var2 ?

PostPosted: Tue Nov 13, 2007 5:37 pm
by cravi_pdy
I think var1 will be abcde, and var2 will be totally 00000.

Re: Redefines: What is var1/ var2 ?

PostPosted: Tue Nov 13, 2007 8:04 pm
by CICS Guy
cravi_pdy wrote:I think var1 will be abcde, and var2 will be totally 00000.
Nope....Not with that redefinition, both datanames contain the same data....

Re: Redefines: What is var1/ var2 ?

PostPosted: Thu Nov 29, 2007 1:10 pm
by extasy
Var1 & Var2 are refer to the same COMPUTER STORAGE AREA.
Clearly,the value of VAR1:abcde and the VAR2:abcde. :roll:
Correct me ... IF sth is wrong,thx x:

Re: Redefines: What is var1/ var2 ?

PostPosted: Sun Dec 09, 2007 3:40 pm
by kiran_ragam
hi
Redefines means different data items using same memory location.
there is var1:'abcde' and var2 also have 'abcde' because these 2 variables using same memory.

Re: Redefines: What is var1/ var2 ?

PostPosted: Thu Dec 27, 2007 2:28 pm
by nikhilgalgate
I agree with Kiran

kiran_ragam wrote:hi
Redefines means different data items using same memory location.
there is var1:'abcde' and var2 also have 'abcde' because these 2 variables using same memory.


You may check it practically. :geek:

Re: Redefines: What is var1/ var2 ?

PostPosted: Thu Jan 03, 2008 1:37 pm
by sureshbabu
here var1 is alphanumeric
var2 is numeric
here var1 is given value 'abcd' which is alphbitic
but var2 is numeric ,,the problem is solved
and redefine shoud use same memory location
so can a same memory location can be used for two variables with different pictures
please continue this

Re: Redefines: What is var1/ var2 ?

PostPosted: Tue Jan 15, 2008 2:43 am
by dick scherrer
Hello,

so can a same memory location can be used for two variables with different pictures
Yes, but this will typically cause more problems than providing solutions. It is another of the things that might be done, but should be avoided. The example that started this topic is a rather bad example.

One time when such a redefinition might be used is when input data might be in different formats. Then, care must be taken to ensure that the correct definition is used n the particular part of the code.