Extracting data from an input file using SORT to different output files not providing expected data

4.9k Views Asked by At

I am using SORT to process an input file and extract records that match three different criteria. The criteria is laid out in the control statements. I am looking for fields that match the text GROUND OPERATIONS, TECHNICAL OPERATI and AIRPORT TRANSFERS. I want records from the input that match each of the conditions to be written to a corresponding output file. The DDs for the output file are SORTOF01, SORTOF02 and SORTOF03 respectively.

I can see there are records that match my criteria in the input file but when executed the SORT completes but no records are selected. I’m missing something but I don’t know what it is. The JCL and control statements for the SORT are supplied below.

//PROB3   EXEC PGM=SORT                                      
//SORTIN  DD DSN=XXX.T.KR0Z1N99.RU02.FTPGEN.THOTLNON,DISP=SHR
//SORTOF01 DD DSN=XXX.T.KR0Z1N99.RU02.FTPGEN.THOTLN01,       
//           DISP=(NEW,CATLG,DELETE),                        
//           LIKE=XXX.T.KR0Z1N99.RU02.FTPGEN.THOTLNON        
//SORTOF02 DD DSN=XXX.T.KR0Z1N99.RU02.FTPGEN.THOTLN02,       
//           DISP=(NEW,CATLG,DELETE),                        
//           LIKE=XXX.T.KR0Z1N99.RU02.FTPGEN.THOTLNON        
//SORTOF03 DD DSN=XXX.T.KR0Z1N99.RU02.FTPGEN.THOTLN03,       
//           DISP=(NEW,CATLG,DELETE),                        
//           LIKE=XXX.T.KR0Z1N99.RU02.FTPGEN.THOTLNON        
//SYSPRINT DD SYSOUT=*                                       
//SYSOUT   DD SYSOUT=*                                       
//SYSIN    DD *                                              
  SORT FIELDS=COPY                                           
  INCLUDE COND=(93,3,CH,EQ,C'YES')                           
  OUTFIL FILES=01,INCLUDE=(73,20,CH,EQ,C'GROUND OPERATIONS') 
  OUTFIL FILES=02,INCLUDE=(73,20,CH,EQ,C'TECHNICAL OPERATI') 
  OUTFIL FILES=03,INCLUDE=(73,20,CH,EQ,C'AIRPORT TRANSFERS') 
1

There are 1 best solutions below

0
On

Try changing the length from 20 to 17 as below

//SYSIN    DD *                                              
  SORT FIELDS=COPY                                           
  INCLUDE COND=(93,3,CH,EQ,C'YES')                           
  OUTFIL FILES=01,INCLUDE=(73,17,CH,EQ,C'GROUND OPERATIONS') 
  OUTFIL FILES=02,INCLUDE=(73,17,CH,EQ,C'TECHNICAL OPERATI') 
  OUTFIL FILES=03,INCLUDE=(73,17,CH,EQ,C'AIRPORT TRANSFERS') 

Comparing 20 bytes with 17 bytes is probably going to be false


When having problems with sort, Always check the Record-Format, if the RECFM is VB you need to add 4 to all positions