Page 1 of 1

Filter based on a COMP field

PostPosted: Fri Jun 24, 2011 1:00 pm
by maragatham pp
I have a file with a particular field X defined as s9(4) COMP.
My goal is to filter records based on this filed with values greater than 5.

I am using mode V and trying to search with the copybook layout.

5 WS-DAY-COUNT 2/BI > ???

What should be the value that I have to provide as above?
I tried 5 - Records with values less than 5 also gets selected.
I tried 101(Binary 5) - Records with decimal values greater thatn 101 are selected.

Please help.

Re: Filter based on a COMP field

PostPosted: Fri Jun 24, 2011 1:56 pm
by BillyBoyo
You are saying > 101 works (in that it shoes all values greater than 101 decimal) and > 5 doesn't? Would seem odd.

Are you displaying the same field you are filtering on (ie, does the copybook definition you are using match the data). Double check. Check the manual. If one works the other doesn't, it is going to be something "obvious" when you know the answer. Try to take a break, then look at the problem again assuming that you know nothing about it. Do everything from scratch. Something has led you astray this time, so by starting again you might avoid it/find out what it is.

Re: Filter based on a COMP field

PostPosted: Fri Jun 24, 2011 2:44 pm
by maragatham pp
Hi, let me put it this way.
When filtering for comp-3 values we specify - Relational operator and value like x'NNNNc'
Similarly, do we have something for Binary values?

Re: Filter based on a COMP field

PostPosted: Fri Jun 24, 2011 2:53 pm
by BillyBoyo
OK, so X'xxxx' is specifying the value in hexadecimal for you packed fields, so hexadecimal for your binary as well.

Try x'0005', which is what the value five is going to look like in comp pic s9(4). A = 10, B = 11 etc.

If you have bigger numbers, look for a HEX calculator, Windows has it, if you find out how to swap it (view scientific).

Re: Filter based on a COMP field

PostPosted: Fri Jun 24, 2011 10:23 pm
by Ed Goodman
Wait...

You are (or at least seem to be) trying comp-3 formats instead of COMP format. You don't want that trailing "C" that you showed in your example.

If you are trying to find the equivalent of +5 in an S9(4) COMP field, the layout would be: x'0005'

For COMP-3, it would be X'000005C'.

I have made some assumptions here, like your COBOL compiler is using 2 bytes for an s9(4) comp field.

If you want to be certain, use File-Aid to create/edit a record using the copybook, then look at that record in hex.