Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

To Select n records using Sort or ICETOOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
prasannahcp

New User


Joined: 16 May 2005
Posts: 15
Location: Bangalore

PostPosted: Tue Jan 23, 2007 10:28 am    Post subject: To Select n records using Sort or ICETOOL
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 Moderator


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

PostPosted: Tue Jan 23, 2007 9:40 pm    Post subject:
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: 15
Location: Bangalore

PostPosted: Wed Jan 24, 2007 11:48 am    Post subject: Re: To Select n records using Sort or ICETOOL
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    Post subject:
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 Moderator


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

PostPosted: Wed Jan 24, 2007 9:30 pm    Post subject:
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 Moderator


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

PostPosted: Tue Aug 26, 2008 1:37 am    Post subject:
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:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us