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

Group variable


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

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Wed Jan 02, 2008 6:45 pm
Reply with quote

Hi,

Can any body please explain the following.

Below is definition

Code:
01 WS-B.                                                     
   05  WS-B1                 PIC 9(002) VALUE ZEROES.       
   05  WS-B2                 PIC 9(006) VALUE ZEROES.   


I have a check as follows.
Code:
IF WS-B > 0
This check comes to true. icon_eek.gif

But when I give
Code:
IF WS-B > ZEROES
it comes as false.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Jan 02, 2008 6:51 pm
Reply with quote

WS-B in hex is 'F0F0F0F0F0F0F0F0'

when you compare it to 0, that would be a literal 'F040404040404040'

when you compare it to zeroes, that would be a literal 'F0F0F0F0F0F0F0F0'
(you can always look at the object listing generated at compile time to see what is actually being compared.

The compares work at advertised (by ibm).
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Wed Jan 02, 2008 6:57 pm
Reply with quote

Hi Dick,

But then what about following combination.

Code:
01 WS-B                      PIC 9(008) VALUE ZEROES.
 IF WS-B > 0


Here if is turning FALSE. Problem comes when the variable is a group variable.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Jan 02, 2008 7:39 pm
Reply with quote

abin wrote:
Hi Dick,

But then what about following combination.

Code:
01 WS-B                      PIC 9(008) VALUE ZEROES.
 IF WS-B > 0


Here if is turning FALSE. Problem comes when the variable is a group variable.


A group variable is always considered as being ALPHANUMERIC!
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Wed Jan 02, 2008 7:45 pm
Reply with quote

Gotcha icon_smile.gif

Quote:
A structure variable is treated as an alphanumeric variable. It has an implied PICTURE of X(nn), where nn is equal to the length of the structure variable


I am trying to compare the group variable with numeric constant zero.

But again the group variable contains zeroes. It is a comparison of zeroes against zeroes right?. Then I should get FALSE in
Code:

01 WS-B.                                                     
   05  WS-B1                 PIC 9(002) VALUE ZEROES.       
   05  WS-B2                 PIC 9(006) VALUE ZEROES. 
IF WS-B > 0
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Wed Jan 02, 2008 9:04 pm
Reply with quote

A group variable is always considered as being ALPHANUMERIC.

Back to the first reply:

If WS-B in hex is 'F0F0F0F0F0F0F0F0'

When you compare it to 0, that would be a literal 'F040404040404040'
IF 'F0F0F0F0F0F0F0F0' > 'F040404040404040' = TRUE

When you compare it to zeroes, that would be a literal 'F0F0F0F0F0F0F0F0'
IF 'F0F0F0F0F0F0F0F0' > 'F0F0F0F0F0F0F0F0' = False they are equal.

If you want a numeric compare do not use a group item.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Jan 03, 2008 2:32 am
Reply with quote

The following WS-B is NOT an A/N var. Any var w/a PIC is an elementary
item.

Craq Giegerich wrote:
abin wrote:
Hi Dick,

But then what about following combination.

Code:
01 WS-B                      PIC 9(008) VALUE ZEROES.
 IF WS-B > 0


Here if is turning FALSE. Problem comes when the variable is a group variable.


A group variable is always considered as being ALPHANUMERIC!
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Jan 03, 2008 3:14 am
Reply with quote

mmwife wrote:
The following WS-B is NOT an A/N var. Any var w/a PIC is an elementary
item.
Here if is turning FALSE. Problem comes when the variable is a group variable.


A group variable is always considered as being ALPHANUMERIC!

And ws-b = 0 so it is not > 0.
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Thu Jan 03, 2008 9:37 am
Reply with quote

Thanks guys...... you all made the puzzle clear for me. icon_biggrin.gif
Back to top
View user's profile Send private message
roopannamdhari
Warnings : 1

New User


Joined: 14 Sep 2006
Posts: 71
Location: Bangalore

PostPosted: Thu Jan 03, 2008 10:53 am
Reply with quote

Hi,

how can we say that the variable ws-b internally stored in hex formate.

Thanks
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Thu Jan 03, 2008 6:48 pm
Reply with quote

Hex is not a format - it s numbering system - base 16.

A format is something like packed decimal: dd dd dd ds, where d=digit (0-9), and s=sign (F or C or D).
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Jan 03, 2008 7:47 pm
Reply with quote

Craig,

My point was that:

01 WS-B PIC 9(008) VALUE ZEROES.

is not a Group Variable. In spite of the fact that it is an 01 level, it's an elementary variable because it contains a PIC clause.

The fact that it tested false has nothing to do with WS-B being a group item; it's a numeric elementary item and it tested false because it contained numeric zeros which are NOT greater than a numeric 0.
Back to top
View user's profile Send private message
Max Payne

New User


Joined: 13 Dec 2007
Posts: 10
Location: Shanghai

PostPosted: Fri Jan 04, 2008 7:38 am
Reply with quote

Very easy.

in your program, WS-B is 6 bytes, Alphanumeric type.

If it is compared with 0, in fact, it is
WS-B > "0bbbbb" (X'F04040404040')

If it is compared with zero, it is WS-B > "000000" (X'F0F0F0F0F0F0'.)
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 Compare latest 2 rows of a table usin... DB2 1
Search our Forums:

Back to Top