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 Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 1 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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