Page 1 of 1

Using s9(13)v99 in include condition

PostPosted: Wed Jun 06, 2012 5:55 pm
by sunilpatwal
Hi,
Which format should I use in INCLUDE of the sort card if the COBOL PIC clause is S9(13)V99.
For example I want the records with value less then 5000.00 to be included.WHat should be the sort card?
Please help. I tried a lot for this. not sure where I am doing wrong.
INCLUDE COND(140,15,??,LT,5000)

Thanks,

Re: Using s9(13)v99 in include condition

PostPosted: Wed Jun 06, 2012 6:00 pm
by Robert Sample
The V in a COBOL PICTURE is an implied decimal. Using a compare against 5000 in your SORT statement, you are comparing against 50.00, not 5000. You need to change your SORT statement to 500000 to include the decimal digits -- since the decimal point does not exist.

Re: Using s9(13)v99 in include condition

PostPosted: Wed Jun 06, 2012 6:06 pm
by sunilpatwal
Hi Robert,
Thanks for quick reply. The amount mentioned in the above sort card was an example. I had tried with 500000 for 5000, but the results are not as expected. I am not sure about the data format to be used. I had placed ?? in the sort card above. Need help on the data format (ZD, SFF, FI etc) to be used.

Thanks.

Re: Using s9(13)v99 in include condition

PostPosted: Wed Jun 06, 2012 6:12 pm
by Robert Sample
You need to look at the full COBOL definition -- USAGE DISPLAY (the default) is ZD to SORT, COMP-3 is PD to SORT, COMP is BI to SORT, and so forth. If you're not getting the results you expect, you could be using the wrong starting position (if the file is variable), or you could be getting the right results for the data in the file, or .... Perhaps the first question to answer is why do you think the results are wrong? The computer won't lie to you, and it very seldom gets arithmetic wrong, so if the results you're getting don't agree with what you think you should be getting, there's a reason for that to be found.

Re: Using s9(13)v99 in include condition

PostPosted: Wed Jun 06, 2012 9:42 pm
by dick scherrer
Hello,

It may help if you show the field from the input file in hex - only a few values please.

Show what you expect the output to be from these values and what values are in the current output.

Re: Using s9(13)v99 in include condition

PostPosted: Wed Jun 06, 2012 10:58 pm
by skolusu
Sunil

Here is a link which shows DFSORT Formats for COBOL Data Types. http://publibz.boulder.ibm.com/cgi-bin/ ... e1ca60/C.3?

In your case S9(13)V99. is a 15 byte ZD field. So your INCLUDE condition should be
INCLUDE COND=(140,15,ZD,LT,500000)

Re: Using s9(13)v99 in include condition

PostPosted: Thu Jun 07, 2012 1:01 pm
by sunilpatwal
Thanks Robert, Dick and sko,
The problem is resolved now. I had tried everything before coming to the forum. Only silly mistake I did was, did not check that I am working with VB file. Checked later and the sort card worked fine with ZD itself.

Thanks all for help.

Re: Using s9(13)v99 in include condition

PostPosted: Thu Jun 07, 2012 8:28 pm
by dick scherrer
Good to hear it is workinig - thank you for posting the solution :)

d