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
 

 

What's the result of alphabetic when redefined as numeric

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

New User


Joined: 13 Jun 2005
Posts: 24

PostPosted: Tue Nov 15, 2005 12:27 am    Post subject: What's the result of alphabetic when redefined as numeric
Reply with quote

05 WS-VAR1 PIC X(5)

05 WS-VAR2 REDEFINES WA-VAR1 PIC 9(5).

PROCEDURE DIVISION

MOVE 'ABCDE' TO WS-VAR1.

now what is the value of WS-VAR1 and WS-VAR2 ?
Back to top
View user's profile Send private message

mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Nov 15, 2005 6:45 am    Post subject:
Reply with quote

ABCDE
Back to top
View user's profile Send private message
shammiullah

New User


Joined: 13 Jun 2005
Posts: 24

PostPosted: Tue Nov 15, 2005 10:59 pm    Post subject: Re: What's the result of alphabetic when redefined as numeri
Reply with quote

hi,
do u mean to say that both variables will display ABCDE.being a variable declared as 9(5),how a varB can display ABCDE as varA. .
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 16, 2005 6:52 am    Post subject:
Reply with quote

Hi,

No. I was answering the ques:
Quote:
now what is the value of WS-VAR1 and WS-VAR2 ?


DISPLAY will convert some numeric variables, so you can't determine what its value is.

But if you put the vaiable(s) in a data rec then use ispf edit to view it, you'll see "ABCDE".
Back to top
View user's profile Send private message
Hames

New User


Joined: 03 Oct 2005
Posts: 49

PostPosted: Mon Nov 21, 2005 12:45 pm    Post subject:
Reply with quote

Hi shammiullah,

MOVE statement will move the value from one variable to another irrespective of the data type.

So that is why if display the numeric value also it displays ABCDE.

But if you compare the value or do any numeric computation on that variable then it will give error.
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Mon Nov 21, 2005 3:51 pm    Post subject: Redifining
Reply with quote

hi frnd,
In the above case it wont give any error instead it will give the garbage value in WS-VAR2. As per hames once any computation is attempted then u will receive error.
Back to top
View user's profile Send private message
mijanurit
Currently Banned

New User


Joined: 26 Aug 2005
Posts: 33
Location: bangalore

PostPosted: Sun Nov 27, 2005 7:22 pm    Post subject:
Reply with quote

hi summy,

when we use "redefine"?
when we don't use two variable at same time. u initialized WS-VAR1(i.e alphanumeric), if u display it will show "ABCDE". but WS-VAR2 will contain garbage value. if u display WS-VAR2 it will show some garbage value.

try it in lab.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Nov 27, 2005 11:31 pm    Post subject:
Reply with quote

Hi Guys,

That "garbage value" you talk about is still "ABCD" in memory. The so called "garbage" is created by the DISPLAY verb when it attempts to display the contents of WS-VAR2 as it was defined.

I'm not so sure WS-VAR2 will display as "garbage" in this case. Has anybody actually tried to DISPLAY WS-VAR2 containing "ABCDE"?

And remember, there's a difference between a variable "containing" a value and that same variable DISPLAYing as a value. For e.g.:

var-x pix s9(001) comp-3 value 4 will CONTAIN X'4C'. It will DISPLAY D. That's because the code generated by the DISPLAY verb unpacks the field before diplaying it. The unpack changes the X'4C' to an X'C4', which DISPLAYs as a "D".
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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts scheduling between OPC and TWS give u... nsbl IBM Tools 1 Sun Mar 12, 2017 5:35 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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