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
 

 

WS-SEQ > 0 -- result is TURE or FALSE ?

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

New User


Joined: 25 May 2006
Posts: 8
Location: india

PostPosted: Thu Oct 23, 2008 5:10 pm    Post subject: WS-SEQ > 0 -- result is TURE or FALSE ?
Reply with quote

01 ws-misc.
05 ws-seq-x pic x(02)
05 ws-seq-num redefines ws-seq-x pic 9(02)
.....
move 'Z6' to ws-seq-x if ws-seq-num > 0 --------- (this evaluates to false - not able to understand how this is evaluated)
next sentence
else
display 'error'.
......
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7997
Location: Bellevue, IA

PostPosted: Thu Oct 23, 2008 5:17 pm    Post subject:
Reply with quote

Did you use the LIST option on your compile? Did you look at the generated assembler code? Can you understand the generated assembler code?

The EBCDIC hexadecimal value of 'Z6' is E9F6. Since you're comparing a 2-byte field to be greater than zero, the comparison is going to be > 00, which is hexadecimal F0F0. E9F6 is less than F0F0 so of course the comparison is false.

Pull up the COBOL Language Reference and Applications Programming Guide manuals from the link at the top of the page and read them. They tell you exactly how such a comparison will be done.
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: Thu Oct 23, 2008 10:23 pm    Post subject:
Reply with quote

Hello,

Quote:
this evaluates to false - not able to understand how this is evaluated
If you work on the pc or unix you probably "knew" that letters sort higher than numbers. On the mainframe the opposite is true - numbers sort higher than letters.

This is because the mainframe has a different collating sequence than the pc/unix platforms (ebcdic versus ascii).
Back to top
View user's profile Send private message
priyanshupathak

New User


Joined: 25 May 2006
Posts: 8
Location: india

PostPosted: Fri Oct 24, 2008 10:27 am    Post subject: Reply to: WS-SEQ > 0 -- result is TURE or FALSE ?
Reply with quote

Thanks for your replies!

I understand the collating sequence part but my doubt is since WS-SEQ-NUM is numeric and 0 being numeric literal this test falls into 'NUMERIC COMPARISION" -- (correct me if I am wrong )

and so comparision in above reference the WS-SEQ-NUM value Z6 is invalid.....
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Oct 24, 2008 3:58 pm    Post subject:
Reply with quote

Quote:

'NUMERIC COMPARISION


you are wrong.
It is not a numeric compare. you apparently were not too well versed with definitions in your last environment, either.
it is an algebraic compare when signed numerics are involved. In this case, they are display.

suggest you spend some time reading a cobol application programmers guide and understand what a compare in cobol is.

two people have already explained that due to the hex representation of characters and numbers
a compare will function based on the character representation.
numbers are greater than letters. so, any letter will be less than a zero.

Suggest you spend some time and learn the fundamentals of Mainframe and COBOL.
It will save you a lot of time trying to debug problems due to false assumptions.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7997
Location: Bellevue, IA

PostPosted: Fri Oct 24, 2008 5:10 pm    Post subject:
Reply with quote

Quote:
this test falls into 'NUMERIC COMPARISION" -- (correct me if I am wrong
You are wrong; consider yourself corrected. Numeric comparison has a very specific meaning in COBOL and your test does not fall under the meaning.

Quote:
and so comparision in above reference the WS-SEQ-NUM value Z6 is invalid.....
Sure, the value is not valid -- but the comparison still can and will be done. You won't get a S0C7 abend until you actually try to do arithmetic with WS-SEQ-NUM; comparisons involving an invalid numeric DISPLAY field against a literal or alphanumeric field can be done as much as you want.
Back to top
View user's profile Send private message
priyanshupathak

New User


Joined: 25 May 2006
Posts: 8
Location: india

PostPosted: Fri Oct 24, 2008 5:34 pm    Post subject: Reply to: WS-SEQ > 0 -- result is TURE or FALSE ?
Reply with quote

thanks a lot icon_biggrin.gif and will take your advise to polish my mainframe & COBOL skills...
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 2 Sun Mar 12, 2017 5:35 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
This topic is locked: you cannot edit posts or make replies. How to run and see the result of DFH$... lind sh CICS 2 Wed Jul 27, 2016 7:04 pm
No new posts Build record according subtraction re... witsche SYNCSORT 5 Fri Oct 02, 2015 12:53 pm


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