IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Both Redefined variable and original variable can be used?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Guru Prasath

New User


Joined: 04 Jun 2008
Posts: 36
Location: Chennai

PostPosted: Mon Aug 11, 2008 10:28 am
Reply with quote

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
View user's profile Send private message
birdy K

New User


Joined: 05 Mar 2008
Posts: 72
Location: chennai

PostPosted: Mon Aug 11, 2008 10:44 am
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Mon Aug 11, 2008 11:55 am
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Aug 11, 2008 1:47 pm
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Mon Aug 11, 2008 5:00 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Aug 11, 2008 5:17 pm
Reply with quote

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.. icon_smile.gif

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... icon_biggrin.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top