Mainframe JCL to concat the 4 files in column wise, all the files having different number of rows,

1.5k Views Asked by At

Is there is way to concat 4 files in column wise using ICETOOL or syncsort in JCL

For Eg:

enter image description here

enter image description here

1

There are 1 best solutions below

0
John Bradley On

The following code will do what you want. I have based input on files being 80 bytes in length.

My input is as follows:-

File1:-

1RED
1WHITE
1BLUE
1BLUE
1BLUE
1BLUE
1BLUE
1BLUE
1BLUE
1BLUE
1BLUE
1BLUE
1BLUE
1PINK

File2:-

21000
22000
23000
24000
25000

File3:-

3X1
3X2
3X3
3X4
3X5

File4:-

4R1
4R2
4R3
4R4
4R5
4R6
4R7
4R8
4R9
4R10
4R11
4R12
4R13
4R14
4R15

Code will merge the files together as you want and handle instances of different numbers of records, etc.

//STEP1    EXEC PGM=ICETOOL                                                     
//SYSOUT   DD   SYSOUT=*                                                        
//DFSMSG   DD   SYSOUT=*                                                        
//TOOLMSG  DD   SYSOUT=*                                                        
//SYSPRINT DD   SYSOUT=*                                                        
//IN1      DD   DSN=JXB7884.FILE1,DISP=SHR                                      
//IN2      DD   DSN=JXB7884.FILE2,DISP=SHR                                      
//IN3      DD   DSN=JXB7884.FILE3,DISP=SHR                                      
//IN4      DD   DSN=JXB7884.FILE4,DISP=SHR                                      
//M1       DD   DSN=&&M1,                                                 
//         DISP=(MOD,PASS),                                                    
//         DCB=(RECFM=FB,LRECL=328,BLKSIZE=0,DSORG=PS),                         
//         UNIT=SYSDA,                                                          
//         SPACE=(TRK,1)                                                        
//REPORT   DD   DSN=JXB7884.REPORT,                                             
//         DISP=(NEW,CATLG,DELETE),                                             
//         DCB=(RECFM=FB,LRECL=320,BLKSIZE=0,DSORG=PS),                         
//         UNIT=SYSDA,                                                          
//         SPACE=(TRK,1)                                                        
//TOOLIN   DD   *                                                               
  COPY  FROM(IN1) TO(M1) USING(COP1)                                            
  COPY  FROM(IN2) TO(M1) USING(COP2)                                            
  COPY  FROM(IN3) TO(M1) USING(COP3)                                            
  COPY  FROM(IN4) TO(M1) USING(COP4)                                            
  SPLICE FROM(M1) TO(REPORT) ON(321,8,PD) WITHANY  -                            
         KEEPNODUPS                                -                            
         WITH(81,80) WITH(161,80) WITH(241,80)     -                            
         USING(SPL1)                                                            
/*                                                                              
//COP1CNTL DD   *                                                               
  OPTION COPY                                                                   
  OUTREC FIELDS=(1,80,240X,321:SEQNUM,8,PD)                                     
/*                                                                              
//COP2CNTL DD   *                                                               
  OPTION COPY                                                                   
  OUTREC FIELDS=(80X,81:1,80,160X,321:SEQNUM,8,PD)                              
/*                                                                              
//COP3CNTL DD   *                                                               
  OPTION COPY                                                                   
  OUTREC FIELDS=(160X,161:1,80,80X,321:SEQNUM,8,PD)                             
/*                                                                              
//COP4CNTL DD   *                                                               
  OPTION COPY                                                                   
  OUTREC FIELDS=(240X,241:1,80,321:SEQNUM,8,PD)                                 
/*                                                                              
//SPL1CNTL DD   *                                                               
  OUTFIL FNAMES=REPORT,OUTREC=(1,320)                                           
/*