SORT JCL to copy when location of matching data is not known If you wish to copy all the records which have a particular string in the file, but its location may vary or is not known then you can use the following sort card
INCLUDE COND=(1,100,SS,EQ,C’ABC’)
The above sort card will look for string ‘ABC’ anywhere between 1 to 100 bytes in the input file. You can specify the range of cols (start and end) where the search is to be performed. If you are not sure about the range then you can give start position as 1 and end pos as record length of the file. Example JCL is provided below. ; ; ; ; //SORTIN DD DISP=SHR,DSN=USERID.ABC.INPFILE, //SORTOUT DD DSN=USERID.ABC.OUTFILE, // SPACE=(TRK,(30,10),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS) //SORTWK01 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SORTWK02 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SORTWK03 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) INCLUDE COND=(1,100,SS,EQ,C’ABC’)
VLSHRT specifies that records that are too short to contain all of the INCLUDE compare fields are not to be included in the output data set.