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

How to compare 2 flat files using DFSORT?


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sridhar R

New User


Joined: 11 Dec 2010
Posts: 20
Location: India

PostPosted: Mon Aug 06, 2012 7:27 pm
Reply with quote

I have requirement of compare two files for eg:

File1 :

xxx yyy zzzz 5
xxx yyy zzzz 2
xxx yyy zzzz 3

File2 :

xxx yyy zzzz 2
xxx yyy zzzz 6

I want the output in the below order

xxx yyy zzzz 5
xxx yyy zzzz 2
xxx yyy zzzz 3
xxx yyy zzzz 6

This means, just i want to append the record which it is not present in file1 when it compare with file2 (whole record)

If i use SORT---> joinkeys or ICETOOL, I m getting the output but it is in asending or decending order. I dont want to do that. I just want to append the new record

Please advise.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Aug 06, 2012 7:34 pm
Reply with quote

before the JOINKEYS, append a sequence number to file2 during a copy operation.

the output of JOINKEYS should be UNPAIED,F2,ONLY

sort the output of the JOINKEYS on the appended sequence number,
dropping the appended sequence number creating file3

concatenate file1,file3 creating file4.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Aug 06, 2012 7:46 pm
Reply with quote

You want matches, you want all records that are on file 2 and unmatched and all records on file 1 and unmatched?

In other words, "adding" records from file 1 only, to file 2?

Add the sequence numbers suggested, do the join, sort on the sequence numbers, remove them.
Back to top
View user's profile Send private message
Sridhar R

New User


Joined: 11 Dec 2010
Posts: 20
Location: India

PostPosted: Mon Aug 06, 2012 8:02 pm
Reply with quote

Thats right I had an idea about this but could you please tell how we can add sequence numbers.

I mean to say that how we can increment the values?
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


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

PostPosted: Mon Aug 06, 2012 8:25 pm
Reply with quote

Quote:
Thats right I had an idea about this but could you please tell how we can add sequence numbers.


SEQNUM

Also Please update your Mainframe skills

Quote:
Mainframe Skills: 6 Months
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Aug 06, 2012 8:44 pm
Reply with quote

using seqnum to reorder file in original order after processing
Back to top
View user's profile Send private message
Sridhar R

New User


Joined: 11 Dec 2010
Posts: 20
Location: India

PostPosted: Mon Aug 06, 2012 9:07 pm
Reply with quote

Thank you very much its working...!!! icon_razz.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Aug 06, 2012 10:57 pm
Reply with quote

Sridhar R,

Use the following DFSORT JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//INA      DD *                                                 
XXX YYY ZZZZ 5                                                   
XXX YYY ZZZZ 2                                                   
XXX YYY ZZZZ 3                                                   
//INB      DD *                                                 
XXX YYY ZZZZ 2                                                   
XXX YYY ZZZZ 6                                                   
XXX YYY ZZZZ 1                                                   
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  JOINKEYS F1=INA,FIELDS=(1,15,A)                               
  JOINKEYS F2=INB,FIELDS=(1,15,A)                               
  JOIN UNPAIRED                                                 
  REFORMAT FIELDS=(F1:1,89,?,F2:1,89)                           
  INREC IFOUTLEN=89,IFTHEN=(WHEN=(90,1,CH,EQ,C'2'),BUILD=(91,89))
  SORT FIELDS=(81,9,CH,A),EQUALS                                 
  OUTREC BUILD=(1,80)                                           
//*                                                             
//JNF1CNTL DD *                                                 
  INREC OVERLAY=(81:C'1',SEQNUM,8,ZD)                           
//*                                                             
//JNF2CNTL DD *                                                 
  INREC OVERLAY=(81:C'2',SEQNUM,8,ZD)                           
//*
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 07, 2012 2:16 am
Reply with quote

hey! look at that.
i was almost close to kolusu's solution.
Back to top
View user's profile Send private message
Sridhar R

New User


Joined: 11 Dec 2010
Posts: 20
Location: India

PostPosted: Tue Aug 07, 2012 12:54 pm
Reply with quote

Thanks to all its working...icon_smile.gif
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top