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 REMOVE DUPLICATES FROM DIFFERENT FILE AND NOT FROM SAME

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
vina2010

New User


Joined: 06 Sep 2010
Posts: 19
Location: Bangalore

PostPosted: Fri Mar 02, 2012 11:04 pm    Post subject: TO REMOVE DUPLICATES FROM DIFFERENT FILE AND NOT FROM SAME
Reply with quote

Hi

I have a requirement to remove duplicates from two different file if it has duplicates in two different files not in the same. If the duplicates are in the same file then the duplicates should not be removed.

For Example:

File 1 has

AAAAAAA,1234
ZZZZZZZ,3452

File 2 has

AAAAAAA,1234
BBBBBBB,2345
BBBBBBB,2345
CCCCCC,5678

File 3 should have

BBBBBBB,2345
BBBBBBB,2345
CCCCCC,5678
ZZZZZZZ,3452

(order is not important)

Can anyone please guide to acheive this via JCL sorts? I need to consider both the fields in the sort separated by comma.
Back to top
View user's profile Send private message

elango_K

New User


Joined: 18 Aug 2011
Posts: 44
Location: India

PostPosted: Fri Mar 02, 2012 11:57 pm    Post subject:
Reply with quote

This can be achieved using JOINKEYS.

Code:

//SYSIN    DD *                                         
  OPTION  COPY                                           
  JOINKEYS FILE=F1,FIELDS=(1,12,A)                       
  JOINKEYS FILE=F2,FIELDS=(1,12,A)                       
  JOIN UNPAIRED,F1,F2,ONLY                               
  REFORMAT FIELDS=(F1:1,12,F2:1,12)                     
  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,24)),               
         IFTHEN=(WHEN=(1,1,CH,EQ,C' '),BUILD=(1:13,12)) 
  OUTFIL FNAMES=SORTOUT,REMOVECC,BUILD=(1,12)           
//*                                                     


Output

Code:

BBBBBBB,2345
BBBBBBB,2345
CCCCCCC,5678
ZZZZZZZ,3452
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: Sat Mar 03, 2012 12:21 am    Post subject:
Reply with quote

Here are two more ways to do it with DFSORT's JOINKEYS (I assumed the input files have FB/80):

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/80)
//IN2 DD DSN=... input file2 (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(1,15,A)
  JOINKEYS F2=IN2,FIELDS=(1,15,A)
  JOIN UNPAIRED,F1,F2,ONLY
  REFORMAT FIELDS=(F1:1,80,F2:1,80,?)
  OPTION COPY
  INREC IFTHEN=(WHEN=(161,1,CH,EQ,C'1'),BUILD=(1,80)),
        IFTHEN=(WHEN=NONE,BUILD=(81,80))
/*


Code:

//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/80)
//IN2 DD DSN=... input file2 (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(1,15,A)
  JOINKEYS F2=IN2,FIELDS=(1,15,A)
  JOIN UNPAIRED,F1,F2,ONLY
  OPTION COPY
  OUTFIL VTOF,BUILD=(5,80)
/*
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am


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