Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 ISSUE IN copying Sequential file reco... thesumitk JCL & VSAM 2 Wed Dec 13, 2017 3:07 pm
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
No new posts ICETOOL - RESIZE DYNAMICALLY kranthikumarb DFSORT/ICETOOL 0 Tue Nov 21, 2017 5:30 pm
No new posts Increment number for every group of r... srajendran2 DFSORT/ICETOOL 7 Thu Nov 09, 2017 10:31 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us