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
 

 

How to get the unmatched records after the SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: How to get the unmatched records after the SORT
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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

Moderator Team Head


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

PostPosted: Fri Apr 06, 2007 11:35 pm    Post subject: Re: How to get the unmatched records after the SORT
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    Post subject: thnx all
Reply with quote

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

New User


Joined: 17 Mar 2007
Posts: 30
Location: USA

PostPosted: Sun Apr 08, 2007 8:53 pm    Post subject: Re: How to get the unmatched records after the SORT
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    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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm


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