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
 

 

Regarding Redefines clause

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Bharti P Manglani

New User


Joined: 13 Mar 2007
Posts: 16
Location: Pune

PostPosted: Thu Aug 02, 2007 6:51 pm    Post subject: Regarding Redefines clause
Reply with quote

In the example below:
05 WS-VAR1 PIC X(5)
05 WS-VAR2 REDEFINES WA-VAR1 PIC 9(5)

In the PROCEDURE DIVISION MOVE 'ABCDE' TO WS-VAR1.What will be the value of WS-VAR1 and WS-VAR2 ?
Back to top
View user's profile Send private message

balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 130
Location: Guntur

PostPosted: Thu Aug 02, 2007 7:06 pm    Post subject:
Reply with quote

hi Bharti,

even though you give alphanumeric value to numeric variable which is a redefined variable,since it is sharing the same memory both will give the same output.

ws-var1 will have 'ABCDE'
ws-var2 will have 'ABCDE'

even though you declare that alphanumeric as alphabetic the result will be the same as above i said.

need any clarification feel free to ask
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 02, 2007 7:15 pm    Post subject:
Reply with quote

balakrishna reddy,
Code:

MOVE 'ABCDE' TO WS-VAR1


that is an alpha literal being moved to an x-type (alphanumeric) field.

WS-VAR2 is defined as numeric.
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 130
Location: Guntur

PostPosted: Thu Aug 02, 2007 7:38 pm    Post subject:
Reply with quote

hi dbz,

In redefined clause the same memory is being accessed by two different variables irrespective of the type declaration, even though you move alphanumeric value to first variable,

when you print the second variable it points to the same memory area where we have moved previously the alphanumeric value.

in short we can say like its a type of saving memory.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Aug 03, 2007 12:22 am    Post subject:
Reply with quote

Hello,

Both variables occupy the same bytes of storage.

If the numeric definition is used and the content is not a valid numeric, an error will be raised. The most common is a s0c7.
Back to top
View user's profile Send private message
Bharti P Manglani

New User


Joined: 13 Mar 2007
Posts: 16
Location: Pune

PostPosted: Fri Aug 03, 2007 11:36 am    Post subject:
Reply with quote

dick scherrer wrote:
Hello,

Both variables occupy the same bytes of storage.

If the numeric definition is used and the content is not a valid numeric, an error will be raised. The most common is a s0c7.


But as the same memory space is occupied, will it lead to a S0C7 even in this case?

Thanks Balakrishna for your response, I think as same memory space is occupied both variables displayed will show ABCDE.
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 130
Location: Guntur

PostPosted: Fri Aug 03, 2007 1:02 pm    Post subject:
Reply with quote

Hi bharti,

Quote:

But as the same memory space is occupied, will it lead to a S0C7 even in this case?


until and unless you use non valid numeric value in any arithmetic or logical operations you will not get soc7 abend.

we are on the safer side up to moves.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Fri Aug 03, 2007 1:13 pm    Post subject:
Reply with quote

Bharti P Manglani wrote:
Thanks Balakrishna for your response, I think as same memory space is occupied both variables displayed will show ABCDE.

Did you try displaying numeric variable? it should show 12345 as far as know. (havent checked it so not sure) Contents will be 'C1C2C3C4C5'X in that memory space.
There will be no S0C7 in this case even if add operation is done on the number. Give it a try.
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 130
Location: Guntur

PostPosted: Fri Aug 03, 2007 2:49 pm    Post subject:
Reply with quote

hi agkshirsagar,


Quote:

Did you try displaying numeric variable? it should show 12345 as far as know


i have tried it and when i displayed those two variables output is :
Code:


ABCDE             -------for alphanumeric variable
ABCDE             -------for numeric variable.

Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Fri Aug 03, 2007 3:45 pm    Post subject:
Reply with quote

Bala,
I had answered a similar question before. After you add any value to 'ABCDE' for instance
Add 1 to ws-var2 you will get 12346. (In last post I clearly missed that icon_redface.gif )
See below thread for reference.
http://www.ibmmainframes.com/viewtopic.php?t=19789
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 130
Location: Guntur

PostPosted: Fri Aug 03, 2007 6:29 pm    Post subject:
Reply with quote

hi agkshirsagar,

i have gone through that topic you have referenced,

i have tried it and same output is coming which you have said.

thanks agkshirsagar i have learned a new thing icon_biggrin.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Aug 03, 2007 7:06 pm    Post subject:
Reply with quote

Hello,

Now that you have learned this - i strongly recommend that you do not use it.

Instead of the letters A-I and J-R (+/- 1-9), try S-Z. The result will not be so friendly.
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 Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts [SQL0029] INTO clause missing from em... HABBIE DB2 2 Fri Sep 04, 2015 3:54 pm
No new posts 3-D Table with nested DEPENDING ON Cl... VivekKhanna COBOL Programming 5 Sat Aug 08, 2015 11:18 pm
No new posts when=group clause: question about the... tuxama DFSORT/ICETOOL 2 Thu Mar 26, 2015 12:51 pm
No new posts Another redefines in COBOL RahulG31 COBOL Programming 1 Fri Mar 20, 2015 4:09 am


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