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 

2 File Matching Using Sort

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
nbdtrjk1
Beginner


Joined: 12 Apr 2007
Posts: 76
Topics: 41

PostPosted: Tue Sep 01, 2009 8:51 am    Post subject: 2 File Matching Using Sort Reply with quote

All

Can anybody please provide me a solution in JCL for the below requirement:

I have two files in which FILE 1 has unique key and FILE 2 has duplicate keys in alternate positions in each record and the unique key from FILE 1 if it matches with duplicate key In file 2 In any of the positions in a record; such records should be written into output file.
Parameters:
File 1: FB, Record length 756
File 2: VB, Record length 710
Output file: same as File 2

For Example:

File 1 has 2 unique keys in position 3 of length 27

Position 3 to 29 is the key

Code:
K1ABC111111111111111111111111
K2XYZ222222222222222222222222


File 2 has duplicate keys of length 27 in two positions: 9 and 93

Code:
R1R1R1R1R ABC111111111111111111111111      abc111111111111111111111111                                     
R2R2R2R2Rabc111111111111111111111111        ABC111111111111111111111111           
R3R3R3R3RXYZ222222222222222222222222        xyz222222222222222222222222
R4R4R4R4Rxyz222222222222222222222222        XYZ222222222222222222222222
R5R5R5R5RDEF333333333333333333333333        def333333333333333333333333
R6R6R6R6R def333333333333333333333333       DEF333333333333333333333333
R7R7R7R7R ABC111111111111111111111111      ghi111111111111111111111111                                     
R8R8R8R8Rghi111111111111111111111111         ABC111111111111111111111111

Desired OUTPUT FILE:

R1R1R1R1R ABC111111111111111111111111      abc111111111111111111111111                                     
R2R2R2R2Rabc111111111111111111111111        ABC111111111111111111111111           
R3R3R3R3RXYZ222222222222222222222222        xyz222222222222222222222222
R4R4R4R4Rxyz222222222222222222222222        XYZ222222222222222222222222
R7R7R7R7R ABC111111111111111111111111      ghi111111111111111111111111                                     
R8R8R8R8Rghi111111111111111111111111         ABC111111111111111111111111


The order of output records should be same as the one in File 2.
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: Tue Sep 01, 2009 9:56 am    Post subject: Reply with quote

nbdtrjk1,

The following DFSORT/ICETOOL JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DUMMY,DCB=(LRECL=80,RECFM=FB,BLKSIZE=27920)             
//SORTOUT  DD DSN=&&H,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)             
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                   
  OUTFIL FTOV,REMOVECC,HEADER1=(C'HDR',80:X) 
//*                       
//STEP0200 EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//IN       DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT             
//         DD DSN=your UNQ vb 756 lrecl file,DISP=SHR
//         DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT             
//         DD DSN=your DUPS vb 710 lrecl file,DISP=SHR
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE),LRECL=718 
//OUT      DD SYSOUT=*                                               
//TOOLIN   DD *                                                       
  SORT FROM(IN) USING(CTL1)                                           
  SORT FROM(T1) USING(CTL2)                                           
//CTL1CNTL DD *                                                       
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,45X,5)),                         
  IFTHEN=(WHEN=GROUP,BEGIN=(50,3,CH,EQ,C'HDR'),PUSH=(5:ID=1,7:SEQ=8)),
  IFTHEN=(WHEN=(5,1,ZD,EQ,1),OVERLAY=(23:52,27)),                     
  IFTHEN=(WHEN=(5,1,ZD,EQ,2),OVERLAY=(23:58,27))                     
  SORT FIELDS=(23,27,CH,A),EQUALS                                     
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(15:SEQNUM,8,ZD,RESTART=(23,27))),
  IFTHEN=(WHEN=GROUP,BEGIN=(15,8,ZD,EQ,1),PUSH=(6:5,1))               
  OUTFIL FNAMES=T1,INCLUDE=(5,2,ZD,EQ,21),BUILD=(1,4,7,8,50)         
//CTL2CNTL DD *                                                       
  SORT FIELDS=(5,8,CH,A)                                             
  OUTFIL FNAMES=OUT,BUILD=(1,4,13)                                   
/*

_________________
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 -> Job Control Language(JCL) 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