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 

Write matching records into a o/p file

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


Joined: 03 Oct 2005
Posts: 70
Topics: 34

PostPosted: Fri Mar 30, 2007 7:19 am    Post subject: Write matching records into a o/p file Reply with quote

I have :
File1:
Rec Length=25
Code:

000038156N274622948048972
000038156Y706784028025244
000065932Y848979845546364
000068763Y848979845546364

File2:
Rec Length =9
Code:

000065932
000001146
000038156
000087453

I want the O/P file as:
File3:
Rec Length =25
Code:

000065932Y848979845546364
000038156N274622948048972
000038156Y706784028025244

A record is fetched from the File2 and is compared with the File1(File2 contains only 9 bytes and only first 9 bytes from the file1 should be compared) and all the matching records are written out(Dups allowed).

I searched this forum to get some knowledge on splice and using the following jcl:
Code:

//jOB CARD                                                 
//STPORB03 EXEC PGM=ICETOOL,COND=(04,LT)                     
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN1      DD DSN=FILE1,     
//           DISP=SHR                                       
//IN2      DD DSN=FILE2,                   
//           DISP=SHR                                       
//OUT12    DD DSN=OUTPUT FILE,           
//           DISP=(NEW,CATLG,DELETE),                       
//           SPACE=(CYL,(200,200),RLSE),                     
//           UNIT=SYSDA,                                     
//           DCB=(RECFM=FB,LRECL=25,BLKSIZE=25)             
//T1       DD DSN=&&T1,UNIT=SYSDA,                           
//           SPACE=(CYL,(200,200),RLSE),                     
//  DISP=(MOD,PASS)                                         
//TOOLIN    DD *                                             
   COPY FROM(IN1) TO(T1) USING(CTL1)   
   COPY FROM(IN2) TO(T1) USING(CTL2)   
   SPLICE FROM(T1) -                   
   ON(1,9,CH) -                         
   WITH(1,9) -                         
   WITH(1,9) -                         
   TO(OUT12) USING(CTL3)               
 /*                                     
 //CTL1CNTL DD *                       
   SORT FIELDS=COPY                     
 /*                                     
 //CTL2CNTL DD *                       
   SORT FIELDS=COPY                     
 /*                                     
 //CTL3CNTL DD *                       
   OUTFIL FNAMES=OUT12                 
 /*     


This is putting all the repeated records from the File1 only. Its not taking the consideration of File2.
Please suggest.

Thanks,
Thrivikram.
Back to top
View user's profile Send private message Send e-mail
expat
Intermediate


Joined: 01 Mar 2007
Posts: 475
Topics: 9
Location: Welsh Wales

PostPosted: Fri Mar 30, 2007 7:37 am    Post subject: Reply with quote

To save a bit of processing power,
Code:

//INFILE   DD DSN=FILE1,DISP=SHR
//         DD DSN=FILE2,DISP=SHR


Try it using ALLDUPS keyword
_________________
If it's true that we are here to help others,
then what exactly are the others here for ?
Back to top
View user's profile Send private message
expat
Intermediate


Joined: 01 Mar 2007
Posts: 475
Topics: 9
Location: Welsh Wales

PostPosted: Fri Mar 30, 2007 7:38 am    Post subject: Reply with quote

Using the JCL above, you don't have to copy both files into T1.
_________________
If it's true that we are here to help others,
then what exactly are the others here for ?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Mar 30, 2007 8:13 am    Post subject: Reply with quote

Thrivkram ,

Please search before posting. Check this link

http://www.mvsforums.com/helpboards/viewtopic.php?t=5399

Quote:

Using the JCL above, you don't have to copy both files into T1.


Expat,

Your suggestion will NOT work as the OP mentioned that file1 has duplicates. So if you use ALLDUPS parm it will select a NON matching key also.

And SORT does not allow 2 different FB LRECL datasets to be concatenated.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
expat
Intermediate


Joined: 01 Mar 2007
Posts: 475
Topics: 9
Location: Welsh Wales

PostPosted: Fri Mar 30, 2007 8:38 am    Post subject: Reply with quote

Kolusu,

It's Friday and it's been a long week.
Yeah, I missed the bit about different record lengths. Embarassed

But how will ALLDUPS select a non matching key ?
_________________
If it's true that we are here to help others,
then what exactly are the others here for ?
Back to top
View user's profile Send private message
samlwho
Beginner


Joined: 08 Feb 2007
Posts: 21
Topics: 2

PostPosted: Fri Mar 30, 2007 9:04 am    Post subject: Reply with quote

T,

This syncsort will do what you need.
Code:

//SRTFIL1  EXEC PGM=SORT,COND=(0,LT)                       
//SYSIN    DD *                                             
 JOINKEYS FILE=F1,                                         
           FIELDS=(001,009,A)                               
 JOINKEYS FILE=F2,                                         
           FIELDS=(001,009,A)                               
  REFORMAT FIELDS=(F1:001,025)     *ALL OF FILE ONE ON MATCH
  SORT     FIELDS=COPY                                     
  OUTFIL   FNAMES=MTCH01                                   
//SORTJNF1 DD DSN=your input file1,DISP=SHR                   
//SORTJNF2 DD DSN=your input file2,DISP=SHR                   
//*                                                         
//MTCH01   DD DSN=D.MVSJOIN,DISP=(NEW,CATLG,DELETE)   
//*
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Mar 30, 2007 9:34 am    Post subject: Reply with quote

expat wrote:
Kolusu,

It's Friday and it's been a long week.
Yeah, I missed the bit about different record lengths. Embarassed

But how will ALLDUPS select a non matching key ?


expat,

consider the following example

file : 1
Code:

111111
222222
222222
333333
333333


File : 2
Code:

111111
222222


Now if you concatenate these 2 files and look for all dups, you would also get the 33333 record even though it does not have a match in file2

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Fri Mar 30, 2007 11:32 am    Post subject: Reply with quote

Thrivikram.

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/25)
//IN2 DD DSN=.... input file2 (FB/9)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/25)
//TOOLIN   DD    *
COPY FROM(IN2) TO(T1) USING(CTL1)
COPY FROM(IN1) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,9,CH) -
  WITHALL WITH(1,26) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(26:C'BB')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(26:C'VV')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(26,2,CH,EQ,C'VB'),
    BUILD=(1,25)
/*

_________________
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