Page 1 of 1

How to limit number of output records in sort

PostPosted: Thu Oct 10, 2013 2:20 am
by chenna kotlo
Hi,

Is there any way i can limit the number of output records to a desired count using sort?

for ex:
input file:
ABC111XXX
DEF222YYY
GHT111ZZZ
LMN111QQQ

i want only ABC111XXX and GHT111ZZZ in my output file.
i used
SORT FIELDS=COPY
INCLUDE COND=(4,3,CH,EQ,C'111'),ACCEPT=2

but it gave syntax error as: INVALID INCLUDE OR OMIT STATEMENT OPERAND

sorry for not finding solution if its there already in the manuals

Re: How to limit number of output records in sort

PostPosted: Thu Oct 10, 2013 2:26 am
by Akatsukami
ACCEPT is a keyword of OUTFIL, not INCLUDE.

Re: How to limit number of output records in sort

PostPosted: Thu Oct 10, 2013 2:32 am
by chenna kotlo
Thanks Akatsukami for a quick reply. Is there any way i can get that output? I mean is there any simple sort command which can give me that output?

Re: How to limit number of output records in sort

PostPosted: Thu Oct 10, 2013 2:45 am
by Akatsukami
I have Syncsort, not DFSORT, which does not accept ACCEPT (so to speak), so I cannot test. However, try:
OUTFIL FNAMES=WANTED,INCLUDE=(4,3,CH,EQ,C'111'),ACCEPT=2

Re: How to limit number of output records in sort

PostPosted: Thu Oct 10, 2013 4:04 am
by BillyBoyo
You could also look at STOPAFT. STOPAFT=2 will stop when two records have got through the INCLUDE/OMIT stage. With a COPY operation it won't make much difference, but if you were actually SORTing or MERGEing the data, the STOPAFT would be more efficient.

The big advantage of the ACCEPT is that it can be different values for different OUTFIL groups.

Re: How to limit number of output records in sort

PostPosted: Fri Oct 11, 2013 1:08 am
by chenna kotlo
Akatsukami, I have DFSORT at my work, not Sync sort. I tried in DFSORT it's not working.

Hi BillyBoyo, as far as i know, STOPAFT limits the number of reads of input record.

Re: How to limit number of output records in sort

PostPosted: Fri Oct 11, 2013 2:14 am
by BillyBoyo
The thing is, when you think you know something, but you try it anyway and it doesn't do what you thought, then you know to go back with that new knowledge and better understand the manuals.

So, try INCLUDE COND= and OPTION COPY,STOPAFT=2 with your data and let us know.