Page 1 of 1

Splice on duplicate records

PostPosted: Wed Aug 19, 2009 8:57 am
by mmt_bit
Hi,

I have 2 files
1st file has the following records:

User_Id Credit_Type
111111 Visa
111111 Master
222222 Visa
333333 Hugtel


2nd file has the following records:

User_Id Name
111111 ABC
222222 CDE
333333 FGH


The out required is:

111111 Visa   ABC
111111 Master ABC
222222 Visa   CDE
333333 Hugtel FGH


Please advise.

Thanks

Re: Splice on duplicate records

PostPosted: Wed Aug 19, 2009 8:53 pm
by skolusu
The following DFSORT JCL will give you the desired results. I assumed that your both files have an LRECL of 80 and RECFM FB.

We concatenate 1 line record named HDR before each file so that we can identify the records as to which file it belongs to


//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
HDR                                                                   
//         DD *                                                       
111111 ABC                                                             
222222 CDE                                                             
333333 FGH                                                             
//         DD *                                                       
HDR                                                                   
//         DD *                                                       
111111 VISA                                                           
111111 MASTER                                                         
222222 VISA                                                           
333333 HUGTEL                                                         
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(81:ID=1))   
  SORT FIELDS=(1,6,CH,A),EQUALS                                       
                                                                       
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(83:SEQNUM,8,ZD,RESTART=(1,6))),   
  IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(15:7,10,82:81,1))     
                                                                       
  OUTFIL INCLUDE=(81,2,ZD,EQ,21,AND,1,3,CH,NE,C'HDR'),BUILD=(1,80)     
/*


The output from this job is

111111 VISA    ABC
111111 MASTER  ABC
222222 VISA    CDE
333333 HUGTEL  FGH