View previous topic :: View next topic
|
Author |
Message |
prasannahcp
New User
Joined: 16 May 2005 Posts: 16 Location: Bangalore
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
prasannahcp
New User
Joined: 16 May 2005 Posts: 16 Location: Bangalore
|
|
|
|
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 |
|
|
Alain Benveniste
New User
Joined: 14 Feb 2005 Posts: 88
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
|