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

How to get the unmatched records after the SORT


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Fri Apr 06, 2007 9:26 pm
Reply with quote

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
View user's profile Send private message
paray2x

New User


Joined: 28 Dec 2005
Posts: 21

PostPosted: Fri Apr 06, 2007 10:28 pm
Reply with quote

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
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Fri Apr 06, 2007 10:39 pm
Reply with quote

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
View user's profile Send private message
paray2x

New User


Joined: 28 Dec 2005
Posts: 21

PostPosted: Fri Apr 06, 2007 10:50 pm
Reply with quote

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
View user's profile Send private message
paray2x

New User


Joined: 28 Dec 2005
Posts: 21

PostPosted: Fri Apr 06, 2007 11:02 pm
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Fri Apr 06, 2007 11:35 pm
Reply with quote

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
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sat Apr 07, 2007 1:47 pm
Reply with quote

anyways thanks all
Back to top
View user's profile Send private message
timburkart

New User


Joined: 17 Mar 2007
Posts: 29
Location: USA

PostPosted: Sun Apr 08, 2007 8:53 pm
Reply with quote

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
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top