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 compare 2 flat files using DFSORT?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How to compare 2 flat files using DFSORT?
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Aug 06, 2012 7:46 pm    Post subject: Reply to: How to compare 2 flat files using DFSORT?
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    Post subject:
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

Moderator


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

PostPosted: Mon Aug 06, 2012 8:25 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Reply to: How to compare 2 flat files using DFSORT?
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm


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