Home » SORT » SORT – INCLUDE and OMIT

SORT – INCLUDE and OMIT

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:

INCLUDE COND=(1,2,CH,EQ,C’AR’)

OMIT COND=(1,2,CH,NE,C’AR’)

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.

INCLUDE COND=(1,2,ZD,LE,3,2,ZD)

OMIT COND=(1,2,ZD,GT,3,2,ZD)

As both the fields are of same type, we can make use of FORMAT and write above statements as

INCLUDE COND=(1,2,LE,3,2),FORMAT=ZD

OMIT COND=(1,2,GT,3,2),FORMAT=ZD

For writing constants

  1. Character Strings

    Use the format C’X…X’

    Say you want to include all records with ‘AR’ at first 2 bytes as shown above.

    INCLUDE COND=(1,2,CH,EQ,C’AR’)

NOTE:

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’.

  1. Hexadecimal Strings

    X’yy..yy’

where yy is a pair of hexadecimal digits. For example, X’7FB0′.

  1. Decimal Numbers

    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.

INCLUDE COND=(1,5,FS,EQ,NUM)

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.

INCLUDE COND=(1,5,CH,EQ,C’COBOL’,OR,

1,5,CH,EQ,C’CICS’,OR,

1,5,CH,EQ,C’DB2′,OR,

1,5,CH,EQ,C’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.

 

 

You might also like to look at:

 

 

SORT – CONVERT PD to ZD and BI to ZD
SORT – EDIT FIRST AND LAST RECORD
SORT – EDIT MASK PATTERNS
SORT – EDIT NUMERIC FIELDS (I,T,S)
SORT – FINDREP, IFTHEN and INREC
SORT – How to use VB dataset (VLSHRT)
SORT – INCLUDE and OMIT
SORT – INREC, INCLUDE and OMIT
SORT – JUSTIFY, SQUEEZE and OVERLAY
SORT – LOOKUP AND CHANGE
SORT – OUTPUT DATASET DCB (LRECL,RECFM,BLKSIZE)
SORT – OUTREC – INSERT ZEROES, BLANKS, STRINGS
SORT – OUTREC – TRAN
SORT – PARSE – REFORMAT VARIABLE FIELDS
SORT – Process Order of CONTROL Statements
SORT – REMOVE DUPLICATES AND WRITE THEM TO XSUM
SORT – SET RETURN CODE ‘04’ IF OUTPUT FILE IS EMPTY
SORT – SKIPREC and STOPAFT
SORT – SUM FIELDS
SORT – TO REPLACE A CHAR WITH ANOTHER CHAR – ALTSEQ
SORT – INREC
SORT – SYMBOLS
SORT JOB – SIMPLE COPY
SORT JOIN – TO JOIN TWO FILES BASED ON A KEY
SORT JOIN – UNPAIRED RECORDS INDICATOR


About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s