View previous topic :: View next topic
|
Author |
Message |
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
Hi all
I have 2 input files.
I need the matched records in one file.
and unmatched records in another file.
For matched records i will use SORTXSUM.
But how to get unmatched records.
advance thnx |
|
Back to top |
|
|
paray2x
New User
Joined: 28 Dec 2005 Posts: 21
|
|
|
|
Hi krishna ,
You can use the SPLICE operator in ICETOOL to get these kind of discompare reports. Refer to the IBM Manuals to get complete info on SPLICE with examples.
There is another way of doing it with simple DFSORT.
STEP1:
Take the first file, append a number say '001' to the end of it using OUTREC.
Take the second file, append another number '002' using OUTREC again.
STEP2:
Now, concatenate the two files above and use the sort statement as below.
Sort fields =(give the key used for comparison)
sum fields = (give the positions of the fields you appended in step1, ZD)
Now, you will get records like this.
--> Present only in first file will have value 001 as such
--> Present only in second file will have value 002 as such
--> Present in both will have the summed value 003.
STEP3:
You can use the INCLUDE statements to get the records you want.
You may also have to use OUTREC to lift off the fields used for compare
Though this may have many steps, you'll find it easier to do.
Hope this helps.
Thanks,
Para |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
paray2x
But the input files contain more then one record for each employee
Your suggestion gives only the first existance of the employee.
So how could i get the remaining unmatched records.
This is the code implemented currently
Code: |
COPY FROM(IN2) TO(T1) USING(CPY2)
SPLICE FROM(T1) TO(OUT1) ON(2,10,CH)-
WITH(119,1) KEEPBASE USING(CPY3)
/*
//CPY1CNTL DD *
OUTREC FIELDS=(1,117,118:C'11',120:X)
/*
//CPY2CNTL DD *
OUTREC FIELDS=(1,117,118:C'22',120:X)
/*
//CPY3CNTL DD *
OUTFIL FNAMES=OUT1,INCLUDE=(118,2,CH,EQ,C'12'),BUILD=(1,120)
OUTFIL FNAMES=OUT2,INCLUDE=(118,2,CH,EQ,C'11'),BUILD=(1,120)
OUTFIL FNAMES=OUT3,INCLUDE=(118,2,CH,EQ,C'22'),BUILD=(1,120)
/* |
|
|
Back to top |
|
|
paray2x
New User
Joined: 28 Dec 2005 Posts: 21
|
|
|
|
Krishna,
I think your files have mutiple records for the key that you use for comparison.
--> You will get the unmatched keys by using the method I told you or by using SPLICE
---> You will certainly come know in which file these keys are present by referring to the summed value.
--> Now you can concatenate the file which contains the unmatched keys alone in one file and your input file as the second one with keys in the same position.
Make sure that your source file contains all the fields other than the key and the mismatch file contains only the key+spaces for other fields
--> use the SELECT operator in ICETOOL and specify ALLDUPS so that you get all the records.
Example :
SELECT FROM(IN) TO(OUT) ON(2,10,CH) ALLDUPS
--> next step you can eliminate the "key only" records using an INCLUDE as they will be having spaces for the fields other than the key
Does this answer you?
Thanks,
Para |
|
Back to top |
|
|
paray2x
New User
Joined: 28 Dec 2005 Posts: 21
|
|
|
|
Krishna,
I just now figured that the above method will not work as your input files may have other keys also with more than one occurence.
These also will be given in the output.
I'm sorry for not thinking of this before.
Now your only choice is to use SPLICE again with the mismatch keys in one file and your input file as the XREF file.
or if you want to do it quickly and the mismatch count is somewhat less (<=5000) , you can simply convert those keys into ICETOOL INCLUDE statements with the COPY and OVERLAY commands using C and OO.
But you cannot automate this method though.
Thanks,
Para |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Para, the SPLICE and OVERLAY commands are only available in DFSORT. Since the O/P mentioned XSUM, he's using SYNCSORT, which is why this was moved out of the DFSORT Forum. This will require a SYNCSORT or SYNCTOOL solution. |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
anyways thanks all |
|
Back to top |
|
|
timburkart
New User
Joined: 17 Mar 2007 Posts: 29 Location: USA
|
|
|
|
You can find a JCL sample to accomplish this with SYNCSORT at http://www.fresherscircle.com/files/JCL_Tutoral1.doc.
Quote: |
I have 2 input files.
I need the matched records in one file.
and unmatched records in another file.
For matched records i will use SORTXSUM.
But how to get unmatched records. |
Your matched records are considered duplicates and are copied to the SORTXSUM DD while the unmatched records are unique and will go the standards SORTOUT DD.
regards,
tim |
|
Back to top |
|
|
|