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

compare 2 file based on key+retain duplicates ICETOOL SPLICE


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Hariharan BK

New User


Joined: 11 Sep 2011
Posts: 14
Location: India

PostPosted: Thu May 02, 2013 12:04 am
Reply with quote

Hi!

I am working on an requirement where there are 2 files :
FILE 1 - have all accounts with other details and will appear with duplicates.
FILE 2 - have only the account list.

All records in file 1 should be written to o/p file (with dups), provided those accounts are matching with that of file 2.

File 1:

100 XXXXX
100 XXXXY
121 XXXRR
122 RREED

File 2:

100
121

o/p file expected:

100 XXXXX
100 XXXXY
121 XXXRR

Please advise on how to get this requirement done via DFSORT/ICETOOL (SPLICE).

I have tried using SPLICE options like 'WITHALL', 'WITHANY', 'WITHEACH' etc. but the duplicates are getting removed and only 1 record is appearing in output file when there are many in file 1... Please suggest.

Thanks,
Hari
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Thu May 02, 2013 12:38 am
Reply with quote

Hello and welcome to the forum,

You should post the code you are using and the diagnostic output from a run (including the messsage ids).

I suspect you do not need SPLICE, but a JOINKEYS.

There are also topics that do this available in the forum. Use the SEARCH feature (above).
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu May 02, 2013 10:34 am
Reply with quote

Hi Hari,

As d.sch. has already pointed out, you dont need a SPLICE but JOINKEYS.
Assuming that First three character is the key in both the files and you need all the data from file one only, and all the files are FB and LRECL=80, you can try this job:

Code:
//SRT01    EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTJNF1 DD *                                               
100 XXXXX                                                     
100 XXXXY                                                     
121 XXXRR                                                     
122 RREED                                                     
//SORTJNF2 DD *                                               
100                                                           
121                                                           
//*                                                           
//COMMON   DD SYSOUT=*                                       
//*                                                           
//SYSIN    DD *                                               
  JOINKEYS FILE=F1,FIELDS=(1,3,A)                             
  JOINKEYS FILE=F2,FIELDS=(1,3,A)                             
  JOIN UNPAIRED,F1,F2                                         
  OPTION COPY                                                 
  REFORMAT FIELDS=(F1:1,80,?)                                 
  OUTFIL FNAMES=COMMON,INCLUDE=(81,1,CH,EQ,C'B'),BUILD=(01,80)
/*


Output:
Code:
100 XXXXX
100 XXXXY
121 XXXRR
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 02, 2013 3:28 pm
Reply with quote

The sample data shown is already sorted, so no need to let JOINKEYS do it again. By not specifying a JOIN statement, only "matched" records will be included, and the REFORMAT record can specify all the data needed from file F1.

Code:
  JOINKEYS FILE=F1,FIELDS=(1,3,A),SORTED,NOSEQCK
  JOINKEYS FILE=F2,FIELDS=(1,3,A),SORTED,NOSEQCK
  OPTION   COPY
  REFORMAT FIELDS=(F1:1,80)
  OUTFIL   FNAMES=COMMON
Back to top
View user's profile Send private message
Hariharan BK

New User


Joined: 11 Sep 2011
Posts: 14
Location: India

PostPosted: Thu May 02, 2013 5:45 pm
Reply with quote

Many thanks All (mistah kurtz)... It worked fine..

Apologies for not posting the code earlier, as there were environement issues in getting the code into this forum.

Anyways thanks again !!
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu May 02, 2013 7:03 pm
Reply with quote

Hi Hari..You're welcome..I think Bill's solution is simpler and more efficient as per your requirements.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 02, 2013 7:26 pm
Reply with quote

Hey, it is your solution, I've just "tweaked" it for the data shown.

JOINKEYS sorts each data file by default (with OPTION EQUALS).

If either or both of the files are already sorted, then you want to tell JOINKEYS not to Sort, and you can avoid "sequence checking" as well.

If only a match is needed, no need to deal with unmatched for either file. If there is no match marker to drop off, then the REFORMAT record can specify the full and complete output.

I'm sure there are many thousands of JOINKEYS "out there" which work, but which re-sort sorted files :-)
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts IGYPG3178-I when compiling a pgm read... COBOL Programming 6
No new posts FileAid move data from two files to o... Compuware & Other Tools 5
No new posts Sorting date into YYYYMMDD, and creat... DFSORT/ICETOOL 13
No new posts To Sort detail records in a file with... SYNCSORT 5
No new posts Compare the member of two pds on las... DFSORT/ICETOOL 13
Search our Forums:


Back to Top