You can use the INCLUDE OMIT statement in conjunction with other options to select/omit the number of records to be processed, which can reduce processor and data transfer time.
- The INCLUDE and OMIT statements allow you to select records by comparing fields with constants or other fields.
- Only one INCLUDE/OMIT control statement can be specified for an application, either as an INCLUDE or as an OMIT control statement not both.
INCLUDE OMIT Syntax
The INCLUDE statement allows a user to select the records to sort or merge from the input file(s):
INCLUDE COND=(Starting Position,Length,Format,Relational Operator,Constant or compare fields)
Example
SORT FIELDS=COPY INCLUDE COND=(1,2,CH,EQ,C'NY',OR,1,2,CH,EQ,C'NJ', OR,1,2,CH,EQ,C'CT',OR,1,2,CH,…) OR INCLUDE COND=(1,2,CH,EQ,L(C'NY',C'NJ',C'CT',…))
The OMIT statement selects the records the user does not include. It allows a user to skip certain records from the input file(s) from being sorted or merged. Use the OMIT control statement for any or all input records that are not to appear in the output file.
INCLUDE COND=(Starting Position,Length,Format,Relational Operator,Constant or compare fields)
Example
SORT FIELDS=COPY OMIT COND=(1,2,CH,EQ,C'NY',OR,1,2,CH,EQ,C'NJ', OR,1,2,CH,EQ,C'CT',OR,1,2,CH,…) OR OMIT COND=(1,2,CH,EQ,L(C'NY',C'NJ',C'CT',…))
INCLUDE OMIT logical expression
Specifies one or more logically combined relational conditions, based on fields in the input record. If true, the record is either included in or omitted from the output file, depending on which control statement is being used.
COND=ALL Specifies to include all input records in the output file or to omit all input records from the output file, depending on which control statement is being used.
COND=NONE Do not include any input records in the output file or do not omit any input records from the output file, depending on which control statement is being used.
COND=comparison(s) Specifies one or more comparisons that determine which records are to be included or omitted. Two types of comparisons are possible:
- A standard comparison, between two record fields or between a record field and a constant. A binary input field also allows comparison by bit mask or bit pattern.
- A substring comparison, which allows the search for a constant within a field, or for a field value within a constant, or for a pattern constant (wildcard) within a field. Use SS as the format to indicate a substring comparison.
Option | Length | Explanation |
AC | 1 to 256 bytes | EBCDIC translated to ASCII before sort or merge. |
AQ | 1 to 256 bytes | Character, but alternate collating sequence set by. |
ASL | 2 to 256 bytes | Leading ASCII separate sign |
AST | 2 to 256 bytes | Trailing ASCII separate sign |
BI | 1 to 4092 bytes | Binary |
CH | 1 to 4092 bytes | Character |
CLO or OL | 1 to 256 bytes | Leading over punch in 1st 4 bits of field is the sign – X’F’, C, E, or A=Positive, D or B=negative |
CSF/FS | 1 to 16 bytes | Floating sign format |
CSL or LS | 1 to 256 bytes | Leading EBCDIC separate sign |
CST or TS | 1 to 256 bytes | Trailing EBCDIC separate sign |
CTO/OT | 1 to 256 bytes | Zoned decimal, trailing over punch in 1st 4 bits of rightmost byte is the sign X’F’, C, E, or A=Positive, D or B=negative (CTO forces CMP=CLC parm) |
FI | 1 to 256 bytes | Fixed point binary |
FL | 2 to 16 bytes | Normalized floating point |
PD | 1 to 256 bytes | Packed signed decimal |
PD0 | 2 to 8 bytes | Packed decimal. first digit and trailing sign ignored. Used for century window processing. |
SS | Substring | Only allowed for substring comparison tests. |
Y2B | 1 byte | 2 digit binary year treated as a 4-digit year by CENTWIN processing. |
Y2C | 2 byte | 2-digit character treated as a 4-digit year by CENTWIN processing. |
Y2D | 1 byte | 2-digit packed decimal treated as a 4-digit year by CENTWIN processing. |
Y2P | 2 byte | 2-digit packed decimal treated as a 4-digit year by CENTWIN processing. First digit and trailing sign ignored. |
Y2S | 2 byte | 2-digit character or zoned decimal treated as a 4-digit year by CENTWIN processing. |
Y2Z | 2 byte | 2-digit zoned decimal treated as a 4-digit year by CENTWIN processing. Zones are ignored. |
ZD | 1 to 256 bytes | Zoned decimal, trailing overpunch in 1st 4 bits of rightmost byte is the sign X’F’, C, E, or A=Positive, D or B=negative. |
INCLUDE OMIT Relational Condition
The relational condition specifies to perform a comparison or bit logic test. Relational conditions may be combined with AND or OR to form a logical expression. If combined, the following rules apply:
- AND statements evaluated before OR statements, unless using parentheses to change the order of evaluation.Expressions inside parentheses are always evaluated first.Nesting parentheses limited only by amount of available storage.
- Symbols for AND (&) and OR (|) can be used in place of the words.
The comparison operators represent the following conditions:
Option | Explanation |
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 |
BO (or ALL) | All mask bits are 1s (ON) in the input field |
BM (SOME) | Some but not all mask bits are 1s (ON) in the input field |
BZ (NONE) | None of the mask bits is 1 (ON) in the input field |
BNO (NOTALL) | Some or no mask bits are 1s (ON) in the input field |
BNM (NOTSOME) | All or no mask bits are 1s (ON) in the input field |
BNZ (NOTNONE) | All or some mask bits are 1s (ON) in the input field |
Some additional information to know about INCLUDE and OMIT control statements is:
- Floating point compare fields cannot be referenced in either control statement.
- Both control statements are mutually exclusive with the other:
- INCLUDE control statements are mutually exclusive with OMIT control statements.
- OMIT control statements are mutually exclusive with INCLUDE control statements.Any selection can be performed with either an INCLUDE or an OMIT control statement.In the compare fields and decimal self-defining term, +0, 0, and –0 are treated as the same number and compare equal.
- If several relational conditions are joined with a combination of AND and OR logical operators, the AND logical expression is evaluated first.The order of evaluation can be changed by using parentheses inside the COND logical expression.
- IfanychangesaremadetorecordformatsbytheE15orE32user exit routines, the INCLUDE or OMIT control statement must apply to the newest formats.
INCLUDE OMIT Examples
Example: INCLUDE Control Statement
INCLUDE COND=(24,4,PD,LT,28,4,PD,OR,10,2,CH,EQ,C'NY')
Records will be included in the application if the numeric value in the field beginning in byte 24 is less than the numeric value in the field beginning in byte 28 or if the character value in the field beginning in byte 10 is equal to NY.
Example: INCLUDE Control Statement Using a Comparisons
OMIT COND=(27,1,CH,EQ,C'D',&, (22,2,BI,SOME,X'C008',|, 28,1,BI,EQ,B'.1....01'))
Byte 27 contains D AND Bytes 22 through 23 have some, but not all of bits 0, 1, and 12 on OR Byte 28 is equal to the specified pattern of bit 1 on, bit 6 off, and bit 7 on.
Note: The AND and OR operators can be written using the AND and OR signs. Parentheses are used to change the order in which AND and OR are evaluated.
Example: INCLUDE Control Statement Using a Bit Mask
INCLUDE COND=(10,1,BI,ALL,B'01001000') OR INCLUDE COND=(10,1,BI,ALL,X'48')
A binary field (BI) of length 1 byte that starts at column 10 of the record, a comparison operator (ALL), and a bitmask (B’01001000′ in binary, X’48’ in hexadecimal).
Example: INCLUDE Control Statement Using Substring with Wildcard (*)
The following sample control statements illustrate substring comparisons with various forms of pattern (wildcard) constants.
INCLUDE COND=(20,12,SS,EQ,(C’ST’,*,C’KU’))
In this example, a 12-byte field starting in position 20 will be searched for strings that begin with ST and end with KU anywhere in the field, regardless of the characters in between. Hence, records with ST43624KU in positions 22 through 30 and ST12KU in columns 24 to 29 would be included, as well as records with STKU in the field. The record selection would be different if the INCLUDE statement were modified to the following:
Example: INCLUDE Control Statement Using Substring with Wildcard (%)
INCLUDE COND=(20,12,SS,EQ,(C’ST’,%%,C’KU’))
In this case, only the record with ST12KU would be included since only two characters would be allowed between the ST and the KU character constants.
Example: INCLUDE Control Statement Using Substring with Wildcard (*%)
The record selection would also be different if the INCLUDE statement were modified to the following:
INCLUDE COND=(20,12,SS,EQ,(C’ST’,*%%%,C’KU’))
In this case, only the record with ST43624KU would be included, since three or more characters are required between the ST and KU character strings.
Example: INCLUDE Control Statement with & MULTIINDD
In the following example, two files are similar enough to allow them to be sorted together using the MULTIIN PARM, but certain fields are in different locations in the record.
INCLUDE COND=(&MULTIINDD,EQ,C’01’,&,50,20,CH,EQ,C’NEW YORK’, OR,&MULTIINDD,EQ,C’02’,&,35,18,CH,EQ,C’NEW YORK’)
This statement will include only New York records despite differences in the formatting of the input files defined by SORTMI01 and SORTMI02.
Example: Sample INCLUDE Control Statement Using Current Date Constant and Current Date With an Offset
The following INCLUDE control statement illustrates the use of the current date constant and the current date with an offset to include records with dates starting with the current date and spanning through the two week period prior to the current date.
INCLUDE COND=(5,8,ZD,LE,&DATE1P,AND,5,8,ZD,GT,&DATE1P-14)
Example: OMIT Control Statement
OMIT COND=(1,3,ZD,EQ,100,AND,20,1,CH,NE,X'40')
Records will be omitted from the application if the numeric value in the field beginning in byte 1 is equal to 100 and if the character value in byte 20 is not equal to a blank (X’40’).
Example: OMIT Control Statement Using NUM
OMIT COND=(24,3,ZD,EQ,NUM,AND,31,5,ZD,NE,NUM) OMIT COND=(24,3,EQ,NUM,AND,31,5,NE,NUM),FORMAT=ZD
In this example, both statements are equivalent; the latter statement specifies the ZD format using the FORMAT=f subparameter. Records will be omitted from the application if the first field (byte 24 to byte 26) is identified as zoned decimal numeric AND the second field (byte 31 to byte 35) is identified as zoned decimal non-numeric.
INCLUDE OMIT Explanation with JCL
//STEP001 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DSN=XXXXX.YYYYY.INPUT,DISP=SHR //SORTOUT DD DSN= XXXXX.YYYYY.OUTPUT, // DISP=(NEW,CATLG,DELETE),UNIT=3390, // SPACE=(CYL,(5,1)),DCB=(LRECL=22) //SYSIN DD * OMIT COND=(5,1,CH,EQ,C'M') SORT FIELDS=(20,8,CH,A,10,3,FI,D) SUM FIELDS=(16,4,ZD) OPTION DYNALLOC,ZDPRINT OUTREC FIELDS=(10,3,20,8,16,4,2Z,5,1,C' SUM') /*
SYSIN DD statement. DFSORT control statements follow.
- OMIT statement. COND specifies that input records with a character M in position 5 are to be omitted from the output data set.
- SORT statement. FIELDS specifies an ascending 8-byte character control field starting at position 20 and a descending 3-byte fixed-point control field starting at position 10.
- SUM statement. FIELDS specifies a 4-byte zoned-decimal summary field starting at position 16. Whenever two records with the same control fields (specified in the SORT statement) are found, their summary fields (specified in the SUM statement) are to be added and placed in one of the records, and the other record is to be deleted.
- OPTION statement. DYNALLOC specifies that work data sets are to be dynamically allocated using the installation defaults for the type of device and number of devices. ZDPRINT specifies that positive ZD SUM fields are to be printable.
- OUTREC statement. FIELDS specifies how the records are to be reformatted for output. The reformatted records are 22 bytes long and look as follows:
Position | Content |
1-3 | Input positions 10 through 12 |
4-11 | Input positions 20 through 27 |
12-15 | Input positions 16 through 19 |
16-17 | Zeros |
18 | Input position 5 |
19-22 | The character string ‘ SUM’ |