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 

Matching two files on keys and writing to output

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


Joined: 17 Dec 2004
Posts: 14
Topics: 8
Location: Monrovia,California

PostPosted: Sat Dec 10, 2011 6:42 am    Post subject: Matching two files on keys and writing to output Reply with quote

I have two files



File A - LRECL=250,RECFM=FB

----+----1----+----2

********************

ABCD000000047700012

NPTQ000000047700012

ASRA000000047700012

BECC400124431800001

CASA000128559000001



File B - LRECL=250,RECFM=FB

----+----1----+----2

********************

ABCD000000047700012

NPTQ000000047700012

ASRA000000047700012



Output file should contain unmatched records between File A and File B

Key fields for comparison starts in position 6 of both files and of 9 characters



Is this possible using DFSORT?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12382
Topics: 75
Location: San Jose

PostPosted: Sat Dec 10, 2011 8:45 am    Post subject: Reply with quote

Piscesian,

If none of your files have duplicates on the key , then you can use select operator with nodups which will eliminate all the matching records from the both files.

Code:

//STEP0100 EXEC PGM=ICETOOL                             
//TOOLMSG  DD SYSOUT=*                                 
//DFSMSG   DD SYSOUT=*                                 
//IN       DD DSN=Your input file A,DISP=SHR
//         DD DSN=Your input file B,DISP=SHR
//OUT      DD SYSOUT=*                                 
//TOOLIN   DD *                                         
  SELECT FROM(IN) TO(OUT) ON(6,7,CH) NODUPS
//*


If your input does have duplicates , then use the following DFSORT JCL which will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT             
//SYSOUT   DD SYSOUT=*               
//INA      DD DSN=your input FB 250 byte file A,DISP=SHR
//INB      DD DSN=same input FB 250 byte file B,DISP=SHR
//SORTOUT  DD SYSOUT=*               
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  JOINKEYS F1=INA,FIELDS=(6,9,A)
  JOINKEYS F2=INB,FIELDS=(6,9,A)                                     
  JOIN UNPAIRED                                                     
  REFORMAT FIELDS=(F1:1,250,F2:1,250,?)                                 

  OUTFIL IFOUTLEN=250,OMIT=(501,1,CH,EQ,C'B'),
  IFTHEN=(WHEN=(501,1,CH,EQ,C'2'),BUILD=(251,250))
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
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