MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Comparing two files and write non-matching records

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
sivafdms
Intermediate


Joined: 29 May 2007
Posts: 165
Topics: 77

PostPosted: Wed Nov 05, 2008 11:51 am    Post subject: Comparing two files and write non-matching records Reply with quote

Hi,
I have 2 files. I want to compare them by using a key and if the records are present in either file2 ,then I want to write those records to an output file. Key is from col 12 & length four.Both the files have similar RECFM & LRECL.


File1
-----
Code:

SIVA       12348    JAVA
MALL       23478    NET
NISH       34589    TESTING




File2
-----
Code:

SIVA       12348    JAVA
MALLI      23478    NET
AIZAZ      56798    JAVA
NISH       34589    TESTING


I WANT TO WRITE NON-MATCHING INTO OTHER FILE

I.E

File3
-----
Code:

AIZAZ      56798    JAVA



Thanks,
Siva
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Nov 05, 2008 12:02 pm    Post subject: Reply with quote

Your description seems to contradict itself. First you say "if the records are present in either file2 ,then I want to write those records to an output file", but then you say " WANT TO WRITE NON-MATCHING INTO OTHER FILE". So it's unclear if you want to write the matching records or the non-matching records.

Assuming it's the non-matching records as in your Subject title and example, you can use a DFSORT/ICETOOL job like the following:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//CON DD DSN=...  input file1
//    DD DSN=...  input file2
//OUT DD DSN=...  output file
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(12,4,CH) NODUPS
/*


If that's not what you want, then you need to do a better job of explaining what you do want with more details.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sivafdms
Intermediate


Joined: 29 May 2007
Posts: 165
Topics: 77

PostPosted: Wed Nov 05, 2008 10:06 pm    Post subject: Reply with quote

Frank,

Thanks the above job is working fine for non-matching records.
I want to write records that preset only in File02.Below is data in two files.

File01

Code:

SIVA       12348    JAVA
MALLI      23478    NET
NISH       34589    TESTING


File02
Code:

SIVA       12348    JAVA
MALLI      23478    NET
MALLI      98979    M/F     
AIZAZ      56798    JAVA
NISH       34589    TESTING


File03 should have records which are present only in file02

File03
Code:

MALLI      98979    M/F     
AIZAZ      56798    JAVA


Thanks
Siva
Back to top
View user's profile Send private message
amargulies
Beginner


Joined: 10 Jan 2007
Posts: 123
Topics: 0

PostPosted: Thu Nov 06, 2008 9:47 am    Post subject: Reply with quote

Here is a SyncSort for z/OS solution that will provide the desired results:
Code:
//STEP1  EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTJNF1 DD *
SIVA       12348    JAVA
MALLI      23478    NET
NISH       34589    TESTING
//SORTJNF2 DD *
SIVA       12348    JAVA
MALLI      23478    NET
MALLI      98979    M/F     
AIZAZ      56798    JAVA
NISH       34589    TESTING
//SYSIN    DD *                       
   JOINKEYS FILE=F1,FIELDS=(12,4,A)   
   JOINKEYS FILE=F2,FIELDS=(12,4,A)   
   JOIN UNPAIRED,F2,ONLY                   
   SORT FIELDS=COPY     
/*

_________________
Alissa Margulies
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Nov 06, 2008 11:32 am    Post subject: Reply with quote

Siva,

Here's a DFSORT/ICETOOL job for your new requirement:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/80)
//IN2 DD DSN=...  input file2 (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(OUT) ON(12,4,CH) NODUPS USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'1')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'2')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(81,1,CH,EQ,C'2'),
    BUILD=(1,80)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group