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
 

 

Group variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Group variable
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: 6967
Location: porcelain throne

PostPosted: Wed Jan 02, 2008 6:51 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Reply to: Group variable
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

Active Member


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

PostPosted: Thu Jan 03, 2008 6:48 pm    Post subject:
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    Post subject:
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    Post subject: Reply to: Group variable
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    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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts Need Help with : IFTHEN(WHEN=GROUP) Sumanta_89 DFSORT/ICETOOL 1 Wed Apr 19, 2017 5:23 pm


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