DFSORT Omit Substring Search

DFSORT OMIT: Alphanumeric Tests DFSORT OMIT: Allowable comparisons

Substring search is used to filter the records which contain the substring anywhere from the starting position and length specified.


OMIT COND=(Field1 starting position, Field1 Length, SS, 
		 Relational Operator, Substring constant)

Let’s discuss in detail.

Field1 starting positionStarting position of field1 to be compared
Field1 LengthLength of the field1 to be compared
SSSpecifying to SORT the filtering should be done based on the Substring search.
Relation operatorRelational operators like GT, EQ, NE, LT etc,.

EQ 		Equal to
NE 		Not equal to
GT 		Greater than
GE 		Greater than or equal to
LT 		Less than
LE 		Less than or equal to
Substring constantSubstring constant


From the below data, filter the records not having Srinivas in the entire file.


********************************* Top of Data **********************************
00002     Srinivas            Employee                                           
test      test                test
00001     Pawan kumar         Student                                            
******************************** Bottom of Data ********************************

Input Record Layout:

	05 ID			PIC X(05).
	05 FILLER		PIC X(05).
	05 NAME			PIC X(15).
	05 FILLER		PIC X(05).
	05 FILLER		PIC X(40).


000100 //Jobcard
000400 //*                                                                     
000500 //**********************************************************************
000600 //*                                                                     
000700 //* SORT FOR STRING SEARCH IN THE FILE                                  
000800 //*                                                                     
000900 //**********************************************************************
001100 //STEP01   EXEC PGM=SORT                                                
001300 //SORTIN   DD DSN=MTH.SORT.INPUT,DISP=SHR                      
001800 //SORTOUT  DD SYSOUT=*                                                  
001900 //SYSOUT   DD SYSOUT=*                                                  
002400 //SYSIN    DD *                                                         
002401      OMIT COND=(1,80,SS,EQ,C'Srinivas')                              
002410      SORT FIELDS=COPY                                                   
003400 /*                                                                      
****** **************************** Bottom of Data ****************************


********************************* TOP OF DATA **********************************
test      test                test
00001     pawan kumar         student                                              
******************************** BOTTOM OF DATA ********************************

Explaining Solution:

  1. As a first step, need to get the position NAME in the file.
  2. As per requirement, the string can be anywhere in the file. So the starting position is file starting position and the length is the file length which is 80.
  3. As a second step, need to get the type of the String.
  4. From the requirement,the string is alphabetic. So the type is character (CH).
  5. Lastly, the job requirement is to ignore the data with Srinivas. So the constant is "Srinivas".
  6. The OMIT condition for the above requirement with all the data gathered is

  7. OMIT COND=(1,80,SS,EQ,C'Srinivas') 

  8. The above condition specifies that ignore the records where the string found as Srinivas. The remaining records will be copied to output file.
  9. The output would have the records where the record not contains Srinivas anywhere in the record.

DFSORT OMIT: Alphanumeric Tests DFSORT OMIT: Allowable comparisons