View previous topic :: View next topic
|
Author |
Message |
Guru Prasath
New User
Joined: 04 Jun 2008 Posts: 36 Location: Chennai
|
|
|
|
Hi,
I am redefining my 01 variable as below.
01 data-1 pic x (10).
01 data-2 REDEFINES data-1.
02 ws-x pic x(5).
02 ws-y pic x(5).
Can i use both data-1 and data-2 at the same time in my coding?
If the answer is no? what will happen if i use like this? Whether i will face any abend or an err? |
|
Back to top |
|
|
birdy K
New User
Joined: 05 Mar 2008 Posts: 72 Location: chennai
|
|
|
|
Welcome to the forums. You can use Both datas in ur coding. If you need as length of 10, you can use data-1. If you need the length of first or last 5, you can use ws-x or ws-y.Corrections are welcome. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Guru,
Quote: |
Can i use both data-1 and data-2 at the same time in my coding? |
Both(data-1 and data-2) fields will have the same value at any point of time and changing the value in one field will automatically alter the other fields value. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
All descriptions for a redefined area are always in effect. Although the different descriptions share a common storage area, they are treated by the compiler (and at execution time) according to their data format and type and as if they were occupying separate storage areas. So yes, you can use both data-1 and data-2 at the same time.
Quote: |
If the answer is no? |
No answer is yes, you can.
Quote: |
what will happen if i use like this? Whether i will face any abend or an err? |
As answerd, they will contain the same values. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Anuj,
Quote: |
Can i use both data-1 and data-2 at the same time in my coding? |
As I see, this question is not that simple. I guess the OP wants to do something like this-
Code: |
MOVE 'some string' to DATA-1
* to use it somewhere
MOVE 'other string' to ws-x
* to use it somewhere else. |
It means he wants to eat the cake and keep it too. You cant have both. When the second move happens, it disturbs the DATA-1 contents too.
It is just my guess though .. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi Abhijit,
Might be you are right, however, for your guess..I've to make another guess, Amen give me the power to read the minds..
Quote: |
It means he wants to eat the cake and keep it too |
He is still keeping it but "address of cake" is changed now..& if so it violates this "rule"
Quote: |
Although the different descriptions share a common storage area |
common storage area means common address in memory but stomach (second "address of cake" ) & table (first "address of cake" ) are differnt "memory locations".., so if OP is thinking this, I would echo You and rule out this possibility... |
|
Back to top |
|
|
|