IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To Select n records using Sort or ICETOOL


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prasannahcp

New User


Joined: 16 May 2005
Posts: 16
Location: Bangalore

PostPosted: Tue Jan 23, 2007 10:28 am
Reply with quote

Hi,

Here is one requirement, i want to select 10 records(Based on some key) among duplicates we get in a file and also we need to select unique records. if number of duplicates is more than 10 i want to select only first 10 records and if it is less than 10 i want to select all the duplicate records.


Thanks,
Prasanna
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Jan 23, 2007 9:40 pm
Reply with quote

Please show an example of your input records and the expected output records. What is the starting position, length and format of the key you want to use to determine duplicates? What is the RECFM and LRECL of your input file?
Back to top
View user's profile Send private message
prasannahcp

New User


Joined: 16 May 2005
Posts: 16
Location: Bangalore

PostPosted: Wed Jan 24, 2007 11:48 am
Reply with quote

Here is the example

100 AAAA
200 BBBB
200 BBBB
200 BBBB
200 CCCC
200 BBBB
200 BBBB
200 BBBB
200 CCCC
200 BBBB
200 BBBB
200 BBBB
200 CCCC
300 DDDD
300 EEEE
400 FFFF
400 FFFF
400 FFFF
500 GGGG
500 HHHH
600 IIII
700 JJJJ
700 JJJJ
700 KKKK
700 JJJJ
700 JJJJ
700 KKKK
700 JJJJ
700 JJJJ
700 KKKK
700 JJJJ
700 JJJJ
700 KKKK
800 LLLL
900 MMMM

For the above records, taking key as first 3 bytes.

Out put should be

100 AAAA
200 BBBB
200 BBBB
200 BBBB
200 CCCC
200 BBBB
200 BBBB
200 BBBB
200 CCCC
200 BBBB
200 BBBB
300 DDDD
300 EEEE
400 FFFF
400 FFFF
400 FFFF
500 GGGG
500 HHHH
600 IIII
700 JJJJ
700 JJJJ
700 KKKK
700 JJJJ
700 JJJJ
700 KKKK
700 JJJJ
700 JJJJ
700 KKKK
700 JJJJ
800 LLLL
900 MMMM

For key 200 and 700 , first 10 records should come. For remaining keys all records should come.

Thanks,
Prasanna
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Wed Jan 24, 2007 2:11 pm
Reply with quote

You can do this by using the SEQNUM function with the RESTART option. Then you can omit all the records > 10 on that field

Alain
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jan 24, 2007 9:30 pm
Reply with quote

Prasanna,

Like Alain said, you can use a DFSORT job like this. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1 EXEC PGM=ICEMAN                                     
//SYSOUT DD SYSOUT=*                                     
//SORTIN DD DSN=...  input file (FB/80)                     
//SORTOUT DD DSN=...  output file (FB/80)                                   
//SYSIN DD *                                             
  OPTION COPY                                           
  INREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,3))           
  OUTFIL INCLUDE=(81,8,ZD,LE,+10),                       
    BUILD=(1,80)                                         
/*
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Aug 26, 2008 1:37 am
Reply with quote

If you have z/OS DFSORT V1R5 PTF UK90013 (July, 2008) you can now use the new SELECT FIRST(n) function to do this more easily like this.

Code:

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


For complete details on the new FIRST(n) function and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top