October 2005 Technical Tip - SyncSort: Converting variable length records to fixed length

Two months ago I showed you how variable length records are stored on the mainframe. Last month I showed you how to use SyncSort to reformat variable length records. In that example I showed you how to drop fields in the "fixed" portion of the record: the output was still variable length records. This month I will show you how to convert variable length records to fixed length; that is, going from RECFM=VB to RECFM=FB.

We will use our file from last month. Recall the file contains credit card information for four individuals. That data is shown here for convenience:

   File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
 _______________________________________________________________________________ 
 EDIT       U0290.CREDIT.CARDS                              Columns 00001 00061 
 Command ===>                                                  Scroll ===> HALF 
 ****** ***************************** Top of Data ******************************
 =COLS> ----+----1----+----2----+----3----+----4----+----5----+----6-           
 000001 987BILL      QUALLS    035555VISA10002345MAST05001234DISC0100           
 000002 123RUBECCA   ALINIAZEE 011010VISA0000                                   
 000003 786ERIC      ALBERT    022323MAST01003434DISC9999                       
 000004 432JASON     ROGERS    017777DISC0750                                   
 ****** **************************** Bottom of Data ****************************

Note that record descriptor word (RDW) does not show while in edit: column positions do not include the RDW. But SyncSort requires the RDW be referenced, so we must add four (4) to the column positions.

The fixed portion of the record is in positions 1-25, the variable portion is in positions 26 and beyond. We want to create a fixed length record with the data from the fixed portion only. The key to doing so with SyncSort is the use the CONVERT keyword. At the same time, we will sort the data by the ID number, which is in positions 1-3 of the record. SyncSort includes the RDW when determining positions in the input record, so the ID number is really in positions 5-7. The following JCL demonstrates the technique:

   File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
 _______________________________________________________________________________ 
 EDIT       U0290.ISPF.CNTL(VB2FB) - 01.03                  Columns 00001 00072 
 Command ===>                                                  Scroll ===> HALF 
 ****** ***************************** Top of Data ******************************
 000001 //U0290V2F JOB (PRM,0,T),'BILL QUALLS',                                 
 000002 //  CLASS=A,MSGCLASS=T,TIME=(0,59),NOTIFY=U0290                         
 000003 //****************************************************                  
 000004 //*  DELETE PRE-EXISTING DATASET IF ANY              *                  
 000005 //****************************************************                  
 000006 //STEP010 EXEC PGM=IEFBR14                                              
 000007 //DEL1     DD DSN=U0290.CREDIT.CARDS.FB,DISP=(MOD,DELETE),              
 000008 //            UNIT=SYSDA,SPACE=(TRK,0)                                  
 000009 //****************************************************                  
 000010 //*  CONVERT VARIABLE TO FIXED                       *                  
 000011 //****************************************************                  
 000012 //STEP020 EXEC PGM=SORT                                                 
 000013 //SORTIN   DD DSN=U0290.CREDIT.CARDS,DISP=SHR                           
 000014 //SORTOUT  DD DSN=U0290.CREDIT.CARDS.FB,DISP=(NEW,CATLG,DELETE),        
 000015 //            UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE),                        
 000016 //            DCB=(RECFM=FB,LRECL=25,BLKSIZE=0)                         
 000017 //SYSIN    DD *                                                         
 000018   SORT FIELDS=(5,3,CH,A)                                                
 000019   OUTREC FIELDS=(1:5,25),CONVERT                                        
 000020 //SYSOUT   DD SYSOUT=*                                                  
 ****** **************************** Bottom of Data ****************************
Download file here.

We can view the output file with ISPF panel 2:

   File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
 _______________________________________________________________________________ 
 EDIT       U0290.CREDIT.CARDS.FB                           Columns 00001 00025 
 Command ===>                                                  Scroll ===> HALF 
 ****** ***************************** Top of Data ******************************
 000001 123RUBECCA   ALINIAZEE 01                                               
 000002 432JASON     ROGERS    01                                               
 000003 786ERIC      ALBERT    02                                               
 000004 987BILL      QUALLS    03                                               
 ****** **************************** Bottom of Data ****************************

Want to know more about SyncSort? Give us a call! You can always count on Caliber Data Training for top quality education.


Go to the articles index. Written by Bill Qualls. Copyright © 2005 by Caliber Data Training 800.938.1222