Converting A Variable To Fixed Length File

Going to start off the new year right with some JCL DSORT processing!

I want to process a mainframe file on a windows machine so I can use some Java tools (like the Copybook Slurper) to process the file contents. The file contains comp data  so it can't be downloaded as a text file. The binary data upsets the 'new line' characters and you get weirdly formatted data.

As a binary file, I can just read the number of bytes on a line, but with a variable length file, the number of bytes vary. So I have to convert to fixed length file first. Once converted, I can download to a windows machine in binary format and know I can always read the same number of bytes.

In the following example TST.CHNGFILE.TVAR is variable length, the longest record is 1575 bytes long. TST.CHNGFILE.TFIXED will be generated with the last 1571 bytes, since the first four bytes contain the record length.


//TESTJOB JOB TEST,'BOS',CLASS=L,REGION=0M,              
//         MSGCLASS=V,NOTIFY=&SYSUID                      
//****************************************************    
//XXDEL  EXEC PGM=IEFBR14                                 
//DD1    DD   UNIT=DISK,DSN=TST.CHNGFILE.TFIXED,        
//            SPACE=(TRK,(0)),DISP=(MOD,DELETE,DELETE)    
//****************************************************    
//* CONVERT FBA TO FB                                     
//****************************************************    
//SA03FRMT EXEC PGM=SORT                                  
//SYSOUT   DD SYSOUT=*                                    
//SYSPRINT DD SYSOUT=*                                    
//SORTIN   DD UNIT=DISK,DSN=TST.CHNGFILE.TVAR,DISP=SHR
//FBOUT    DD UNIT=DISK,DSN=TST.CHNGFILE.TFIXED,        
//            DCB=(RECFM=FB,LRECL=1571),                  
//            DISP=(,CATLG),SPACE=(TRK,(150,15),RLSE)     
//* VTOF (CONVERT FROM ONE RECORD FORMAT TO ANOTHER)      
//* BUILD(FROM,LENGTH,ETC....)                            
//* OUTREC CAN REPLACE BUILD                              
//SYSIN    DD *                                           
  OPTION COPY                                             
  SORT FIELDS=COPY                                        
  OUTFIL FNAMES=FBOUT,VTOF,BUILD=(5,1571)                 

Check out IBM's sorttrck document and search for VB to FB for more official documentation and options, such as the VFILL parameter.