05 ws-seq-x pic x(02)
05 ws-seq-num redefines ws-seq-x pic 9(02)
move 'Z6' to ws-seq-xif ws-seq-num > 0 --------- (this evaluates to false - not able to understand how this is evaluated)
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.
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
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.
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.
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.