The OMIT control statement filters input records by dropping those that satisfy the condition you specify; all other records are kept and passed to the sort or merge phase. You define the condition with OMIT COND=, using the same syntax as INCLUDE COND= (field position, length, format, operator, value). OMIT is the opposite of INCLUDE: INCLUDE keeps matches and drops the rest; OMIT drops matches and keeps the rest. This page covers OMIT COND= syntax, when to use OMIT instead of INCLUDE, and how both are applied during the input phase.
OMIT is a filter that excludes records. For each input record, DFSORT evaluates the condition in COND=. If the condition is true, the record is dropped—it is not passed to the sort or merge and will not appear in the output. If the condition is false, the record is kept. So OMIT means "drop records that match." It is applied during the input phase, same as INCLUDE. Use OMIT when you want to remove a minority of records (e.g. header/trailer lines, invalid codes, test data) and keep everything else. Use INCLUDE when you want to keep a minority (e.g. only records for one region) and drop everything else.
The syntax is the same as INCLUDE COND=:
1OMIT COND=(start,length,format,operator,value)
start and length define the field to test. format (CH, PD, ZD, BI, etc.) must match the data. operator is EQ, NE, GT, GE, LT, or LE. value is the constant (e.g. C\'X\' for character, or a number for numeric). Records for which (field operator value) is true are omitted (dropped). Records for which it is false are kept.
For the same condition, INCLUDE and OMIT do the opposite:
So if 90% of your records have something other than H in position 1, INCLUDE would keep 10% and OMIT would keep 90%. Choose the one that matches how you think: "keep only these" (INCLUDE) or "drop only these" (OMIT).
1OMIT COND=(1,1,CH,EQ,C'*')
Drops records where the first byte is an asterisk. Keeps all other records. Useful when the first character marks comment or header lines.
1OMIT COND=(80,1,CH,EQ,C' ')
Drops records where byte 80 is a space. Keeps records where byte 80 is not a space. (You might use this to drop blank or trailer lines if your convention puts a space in 80 for those.)
1OMIT COND=(20,4,PD,EQ,0)
Drops records where the 4-byte packed-decimal field at positions 20–23 equals zero. Keeps all records with a non-zero value there.
You can code both. A record is kept only if it passes INCLUDE (if you have one) and does not match OMIT (if you have one). So first the INCLUDE filter is applied—if the record does not match INCLUDE, it is dropped. Then, of the records that passed INCLUDE, any that match OMIT are dropped. The remaining records go to the sort/merge. For clarity, many jobs use only one: either "keep only these" (INCLUDE) or "drop only these" (OMIT).
If you use INREC, the record is reformatted before INCLUDE and OMIT are evaluated. So the positions in your OMIT COND= refer to the reformatted record (after INREC), not the original input. If you do not use INREC, positions refer to the original record.
OMIT is like a bouncer who throws out certain people. You tell the bouncer: "If someone has an X on their hand, don't let them in." Everyone with X gets turned away; everyone without X gets in. INCLUDE is the opposite: "Only let in people with an X." So OMIT = "keep everyone except the ones that match." INCLUDE = "keep only the ones that match."
1. What does OMIT do in DFSORT?
2. When is OMIT applied?
3. OMIT COND=(1,1,CH,EQ,C'*') keeps which records?
4. What is the difference between INCLUDE and OMIT with the same condition?
5. Why would you use OMIT instead of INCLUDE?