Page 1 of 1

How to copy only one record after sorting to SORTOUT.

Posted: Wed Jan 12, 2011 2:10 pm
by esmayeel_s
Hi All,

I have a sort card as below.

INCLUDE COND=(1,13,CH,EQ,C'abc-xyz-data')
SORT FIELDS=(15,4,CH,D,19,2,CH,D,21,2,CH,D,24,6,CH,D)
SORT FIELDS=COPY

It will pickup the rows which contains charector 'abc-xyz-data' in 1 to 13th position and then it will sort the as per the above condition and finally it will write all records to SORTOUT file.

After sorting i want only first record to placed in the SORTOUT. How it can be achived.

Please suggest.

Thanks
Husen

Posted: Wed Jan 12, 2011 2:29 pm
by Anuj Dhawan
Use STOPAFT=1, along with your SORT statements.

Posted: Wed Jan 12, 2011 4:46 pm
by esmayeel_s
I have tried this option before pasting the Query, but it is copying only one record without sorting.

Posted: Wed Jan 12, 2011 10:56 pm
by Frank Yaeger
STOPAFT is processed before sorting so it won't do what you want.

OUTFIL is processed after sorting so ENDREC=1 will do what you want.

Code: Select all

  INCLUDE COND=(1,13,CH,EQ,C'abc-xyz-data') 
  SORT FIELDS=(15,4,CH,D,19,2,CH,D,21,2,CH,D,24,6,CH,D) 
  OUTFIL ENDREC=1
If you have the Oct, 2010 DFSORT PTF, ACCEPT=1 will also work.

For more information on the order of processing for various DFSORT functions, see:

http://publibz.boulder.ibm.com/cgi-bin/ ... FIGSTMTSEQ

Posted: Thu Jan 13, 2011 5:46 pm
by Anuj Dhawan
Thanks Frank. I had my lesson for the day.

Sorry for the wrong information, Husen.

have a good one, :)