Page 1 of 1

Selecting only 10 records-DFSORT

PostPosted: Wed Dec 08, 2010 10:48 am
by ishwarya
Hi all,

I have a requirement to select only 2 records(sequentially or randomly) from a file for a test purpose.The file is like this,

11111 abcd jhgsdkfg jngsdkfjh klafgsf
11111 reyty rrtgrtgrt fgdfgfgfg fgsdgh
11111 wqre qerwerer erwerrtre retrttry
11111 rtrte ewrertrt rwetrtrtre tgertrtr
22222 abcd jhgsdkfg jngsdkfjh klafgsf
22222 reyty rrtgrtgrt fgdfgfgfg fgsdgh
22222 wqre qerwerer erwerrtre retrttry
22222 rtrte ewrertrt rwetrtrtr tgertrtr

I need to select only 2 records from 11111 and 22222 keys.I can use INCLUDE condition if the number of records are few.But I have a very big file having keys count to 1000.Kindly help.

Re: Selecting only 10 records-DFSORT

PostPosted: Wed Dec 08, 2010 11:08 pm
by Frank Yaeger
I don't understand how your Subject "Selecting only 10 records" relates to your question. If your records are already sorted by the key in positions 1-5 and you want the first two records with each key, you can use this DFSORT/ICETOOL job:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file
//OUT DD DSN=...  output file
//TOOLIN   DD   *
SELECT FROM(IN) TO(OUT) ON(1,5,CH) FIRST(2) USING(CTL1)
/*
//CTL1CNTL DD   *
  OPTION COPY
/*



SORTOUT would have:

11111 abcd jhgsdkfg jngsdkfjh klafgsf   
11111 reyty rrtgrtgrt fgdfgfgfg fgsdgh   
22222 abcd jhgsdkfg jngsdkfjh klafgsf   
22222 reyty rrtgrtgrt fgdfgfgfg fgsdgh   


If that's not what you want, then you need to do a better job of explaining what you do want with an example of input and expected output.