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

Compare two unsorted files in JCL


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

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Tue Feb 12, 2013 3:35 pm
Reply with quote

Hi all,

I am trying to implement a JCL which compares two files and writes the matching records into the output file1 and non-matching records into output file2.
The records in it are not sorted.
Two input files have the data from column 1 to 10 of char type.

I have seen other's jobs(JCL) in the internet as well but their logic's are not as exactly I wanted.

Could anyone help me on how to implement this logic ?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Feb 12, 2013 3:53 pm
Reply with quote

Which version of SORT are you using and what release level is it ?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 12, 2013 4:04 pm
Reply with quote

Quote:
The records in it are not sorted.


to compare on some key You will have to sort the files!
Back to top
View user's profile Send private message
tamminenisidhartha
Currently Banned

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Tue Feb 12, 2013 4:23 pm
Reply with quote

Hi Enrico and Expat.
I am posting the code here.

//FSS320V JOB (VV,BOBBY),'SIDDU',NOTIFY=&SYSUID
//STEP010 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=FSS320.INFILE1.PS,DISP=SHR
// DD DSN=R04290.INFILE2.PS,DISP=SHR
//NODUPES DD DSN=FSS320.NODUPES.PS,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(20,10),RLSE),
// DCB=(RECFM=FBA,LRECL=80,BLKSIZE=800,DSORG=PS)
//DUPES DD DSN=FSS320.DUPES.PS,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(20,10),RLSE),
// DCB=(RECFM=FBA,LRECL=80,BLKSIZE=800,DSORG=PS)
//TOOLIN DD *
SELECT FROM (SORTIN) TO (NODUPES) -
ON (11,6,CH) NODUPS
SELECT FROM (SORTIN) TO (DUPES) -
ON (11,6,CH) ALLDUPS
/*

The problem with this code is the duplicate records are being written two times in the output file which contains the duplicate records.
The non duplicate records are being written correct.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Feb 12, 2013 4:26 pm
Reply with quote

Dear tamminenisidhartha,

Do you want to find the duplicates or compare the files?
Back to top
View user's profile Send private message
tamminenisidhartha
Currently Banned

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Tue Feb 12, 2013 4:28 pm
Reply with quote

I want to write the only first duplicate record into a file and non duplicate records into other file.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Feb 12, 2013 4:35 pm
Reply with quote

Suppose your input contains multiple duplicates still you wanted to write the first duplicate record alone to output?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 12, 2013 4:40 pm
Reply with quote

check the manuals for the FIRST keyword
Back to top
View user's profile Send private message
tamminenisidhartha
Currently Banned

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Tue Feb 12, 2013 4:47 pm
Reply with quote

@Pandora Box
Yes Pandora Box.
I want to write only the first duplicate record.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 12, 2013 4:57 pm
Reply with quote

in IT using the proper terminology is essential for good communications

what You are doing ( more or less successfully ) is isolate duplicates / non duplicates regardless of the file they come from

to compare TWO files You need to use the JOINKEYs approach

search the forum and You will find quite a few examples of it
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top