SORT – INCLUDE and OMIT
Include/Omit are the first statements to be processed in a SORT job, even though you have mentioned statements in any order.
So by using INCLUDE/OMIT, we can remove unnecessary records before doing the sorting/merging or copying. This increases the speed of the process as we may have less number of records to process.
As name suggests, INCLUDE is for including selecting records and OMIT is for omitting unnecessary records. You can perform both inclusion and omission by both INCLUDE/OMIT by using the operator NE (Not equal).
Suppose if you want to include records with first 2 chars as AR, the statements look as below:
You can even compare two fields to do omission/inclusion.
Suppose you want omit all the records for which the first 2 bytes is greater than 3rd and 4th byte together. Say 1-2 and 3-4 bytes all are of numeric data.
As both the fields are of same type, we can make use of FORMAT and write above statements as
For writing constants
Use the format C’X…X’
Say you want to include all records with ‘AR’ at first 2 bytes as shown above.
If you want to include a single apostrophe in the string, you must specify it as two single apostrophes. For example, O’NEILL must be specified as C’O”NEILL’.
where yy is a pair of hexadecimal digits. For example, X’7FB0′.
The format for writing a decimal number is:
n…n or ±n…n
where n is a decimal digit. Examples are 24, +24, and -24.
Decimal numbers must not contain commas or decimal points.
Numeric Tests for INCLUDE and OMIT
You can do numeric tests in INCLUDE/OMIT. Suppose you want to include only records with first 5 bytes being numeric.
Use NUM to indicate a test for numerics or non-numerics.
Use EQ to test for numerics, or NE to test for non-numerics.
Use FS format for the field if you want to test for character numerics (‘0′-‘9′ in every byte).
Use ZD format for the field if you want to test for zoned decimal numerics (‘0′-‘9′ in all non-sign bytes; X’F0′-X’F9′, X’D0′-X’D9′ or X’C0′-X’C9′ in the sign byte).
Use PD format for the field if you want to test for packed decimal numerics (0-9 for all digits; F, D or C for the sign).
Substring Search for INCLUDE and OMIT
Below is a INCLUDE statement, to include all the records with first 5 bytes as COBOL, CICS, DB2 and VSAM.
Instead, you can use one of the substring search capabilities of INCLUDE and OMIT to write the statement in a simpler form as:
INCLUDE COND=(1,5,SS,EQ,C’COBOL,CICS ,DB2 ,VSAM ‘)
The length of each string must match the length of the field. Because you are searching for 5 characters, you must add a blank at the end of “VSAM” and “CICS” and 2 blanks at the end of “DB2″, which are each four characters and 3 characters , but not for “COBOL”, which is five characters.