|
View previous topic :: View next topic
|
| Author |
Message |
Hariharan BK
New User
Joined: 11 Sep 2011 Posts: 14 Location: India
|
|
|
|
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
Hariharan BK
New User
Joined: 11 Sep 2011 Posts: 14 Location: India
|
|
|
|
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 |
|
 |
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
| Hi Hari..You're welcome..I think Bill's solution is simpler and more efficient as per your requirements. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
|
|