View previous topic :: View next topic
|
Author |
Message |
mohitsethi
New User
Joined: 19 Apr 2015 Posts: 4 Location: India
|
|
|
|
Hi,
We all know SUM FIELDS=NONE and XSUM works fine and keeps the first record in SYSOUT and all duplicate records in XSUM.
My requirement is that I want all references of DUPLICATE record in another file and all unique records in one file. How can we do it.
Given that sort key is Composite Key of:
Name and Role - SAMANTHA and DEV (col: 3 - 10,20-23)
Example:
01SAMANTHA NNYY112 DEV1PROGRAMMER
01SAMANTHA NNYY112 DEV2MANAGER
01 MICHAEL NNYY121 DEV1PROGRAMMER
01 JAMES YNNY341 MGR4EXECUTIVE
File 1 - Unique records
01 MICHAEL NNYY121 DEV1PROGRAMMER
01 JAMES YNNY341 MGR4EXECUTIVE
File 2 - Non Unique records
01SAMANTHA NNYY112 DEV1PROGRAMMER
01SAMANTHA NNYY112 DEV2MANAGER |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1337 Location: Bamberg, Germany
|
|
|
|
Do not double post your question when you know exactly what SORT product you are using. Also make use of Code tags when presenting data.
The best approach for your requirement might be JOINKEYS. You find plenty of samples here.
Code: |
Name and Role - SAMANTHA and DEV (col: 3 - 10,20-23) |
Your sample output is wrong as DEV1 and DEV2 (Key 20..23) are unique as well for Name SAMANTHA. |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1337 Location: Bamberg, Germany
|
|
|
|
Simplified solution using SYNCTOOL:
Code: |
//SEPARATE EXEC PGM=SYNCTOOL
//IN DD *
01SAMANTHA NNYY112 DEV1PROGRAMMER
01SAMANTHA NNYY112 DEV2MANAGER
01 MICHAEL NNYY121 DEV1PROGRAMMER
01 JAMES YNNY341 MGR4EXECUTIVE
/*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//UNIQ DD SYSOUT=*
//DUPS DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(DUPS) ON(3,10,BI) ON(20,3,BI) ALLDUPS -
DISCARD(UNIQ)
/* |
|
|
Back to top |
|
|
mohitsethi
New User
Joined: 19 Apr 2015 Posts: 4 Location: India
|
|
|
|
Thanks for the code sample Joerg. I am not looking to discard UNIQ and persist that in file1 (UNIQ) and file2 (DUPS).
The key is 20-22 actually. Sorry for the typo.
Thanks,
Mohit
Joerg.Findeisen wrote: |
Simplified solution using SYNCTOOL:
Code: |
//SEPARATE EXEC PGM=SYNCTOOL
//IN DD *
01SAMANTHA NNYY112 DEV1PROGRAMMER
01SAMANTHA NNYY112 DEV2MANAGER
01 MICHAEL NNYY121 DEV1PROGRAMMER
01 JAMES YNNY341 MGR4EXECUTIVE
/*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//UNIQ DD SYSOUT=*
//DUPS DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(DUPS) ON(3,10,BI) ON(20,3,BI) ALLDUPS -
DISCARD(UNIQ)
/* |
|
|
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
If you RTFM, you will see that SELECT with ALLDUPS will copy all duplicate records to the DUPS ddname and DISCARD will copy all other records yo the UNIQ ddname. The records are not discarded.
Garry. |
|
Back to top |
|
|
mohitsethi
New User
Joined: 19 Apr 2015 Posts: 4 Location: India
|
|
|
|
Thanks Garry. I indeed RTFM :-)
Have a great tuesday!!
Garry Carroll wrote: |
If you RTFM, you will see that SELECT with ALLDUPS will copy all duplicate records to the DUPS ddname and DISCARD will copy all other records yo the UNIQ ddname. The records are not discarded.
Garry. |
|
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
mohitsethi wrote: |
Thanks Garry. I indeed RTFM :-)
Have a great tuesday!!
Garry Carroll wrote: |
If you RTFM, you will see that SELECT with ALLDUPS will copy all duplicate records to the DUPS ddname and DISCARD will copy all other records yo the UNIQ ddname. The records are not discarded.
Garry. |
|
At least not with the right keyword. Anyways, Here is the recent post discussing the same which you missed to get it in your search.
ibmmainframes.com/viewtopic.php?t=67928&highlight= |
|
Back to top |
|
|
|