IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

TO REMOVE DUPLICATES FROM DIFFERENT FILE AND NOT FROM SAME


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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 Developer


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

PostPosted: Sat Mar 03, 2012 12:21 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top