Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Both Redefined variable and original variable can be used?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Both Redefined variable and original variable can be used?
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Mon Aug 11, 2008 11:55 am    Post subject: Reply to: Both Redefined variable and original variable can
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

Senior Member


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

PostPosted: Mon Aug 11, 2008 1:47 pm    Post subject:
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: 686
Location: Earth

PostPosted: Mon Aug 11, 2008 5:00 pm    Post subject:
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

Senior Member


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

PostPosted: Mon Aug 11, 2008 5:17 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us