Page 1 of 1

copy first occurence only

PostPosted: Wed Jul 07, 2010 6:30 pm
by ranga_subham
Hi,

I have an input file (LRECL=100,RECFM=FB) as shown below:

record 2010
record 2008
record 2007
record 2010
record 2007
record 2008
record 2010
record 2009
..
..
..
..
record 2008
record 2007


I want to copy only the first occurence of "record 2007" to output.

Please help me with the SORT card.

Thanks.

Re: copy first occurence only

PostPosted: Wed Jul 07, 2010 8:02 pm
by Alissa Margulies
Here is a SyncSort for z/OS job that will produce your requested output:
//SORT1 EXEC PGM=SORT                     
//SORTIN  DD *                             
RECORD 2010 1                             
RECORD 2008 2                             
RECORD 2007 3                             
RECORD 2010 4                             
RECORD 2007 5                             
RECORD 2008 6                             
RECORD 2010 7                             
RECORD 2009 8                             
//SORTOUT DD SYSOUT=*                     
//SYSOUT  DD SYSOUT=*                     
//SYSIN   DD *                             
   INCLUDE COND=(1,11,CH,EQ,C'RECORD 2007')
   SORT FIELDS=COPY,STOPAFT=1       
/*
(I added an extra field in the input data just to make it easier to identify the record included in the output...)

The output produced from the above sort step is:
RECORD 2007 3

Re: copy first occurence only

PostPosted: Wed Jul 07, 2010 8:13 pm
by ranga_subham
Thanks a lot.