Tags

, , ,

SORT – LOOKUP AND CHANGE

You can make use of SORT, to replace a string of the input record with different strings based on the value of that input string.

Suppose you have your input file as below:

DD

PCT

MOVE

INDEX

FILE

And you want to your output to be as below:

DD JCL

PCT CICS

MOVE COBOL

INDEX VSAM

FILE ALL

So here you are relating each keyword in the first 5 bytes of your input file to the language it belongs to.

So your OUTREC statement should look like below.

OUTREC FIELDS=(1,5,X,

1,5,CHANGE=(10,

C’DD’,C’JCL’,

C’PCT’,C’CICS’,

C’MOVE’,C’COBOL’,

C’INDEX’,C’VSAM’),

NOMATCH=(C’ALL’))

You use p, m,CHANGE=(v,find,set,…) to give the position and length of the input field, the length of the output field, and the “table” consisting of pairs of find constants, and set constants or set fields. For example, for the first field in the OUTREC statement above:

  1. The input field starts in position 1.
  2. The length of the input field and find constants is 5.
  3. The length of the output field and set constants is 10.
  4. The first find constant is ‘DD’ (padded with a blank at the end to 5 characters).
  5. The first set constant is ‘JCL’ (padded with blanks at the end to 10 characters).

You can use NOMATCH=(set) to set the output value when an input field value does not match any of the find constants. If you do not specify NOMATCH=(set), DFSORT terminates with an error message when an input field value does not match any of the find constants.

HERE NOMATCH=(C’ALL’) will set the value as ALL for the word FILE in input file as it did not have any matches in CHANGE command.

 

 

You might also like to look at:

 

Important SQL CODES and ABEND CODES
SORT JOIN – TO JOIN TWO FILES BASED ON A KEY
KNOW YOUR MAINFRAME
REXX – INITIAL SETUP
SAS – SAMPLE PROGRAM
SORT – CONVERT PD to ZD IN DISPLAYABLE FORMAT (ZDF)
SORT – Alphanumeric Tests for INCLUDE and OMIT
SORT – EQUALS Option
SORT – PARSE – REFORMAT VARIABLE FIELDS
SORT – FINDREP, IFTHEN and INREC
SORT – JUSTIFY, SQUEEZE and OVERLAY
SORT – LOOKUP AND CHANGE
SORT – CONVERT PD to ZD and BI to ZD
SORT – OUTREC – TRAN
SORT – OUTREC – INSERT ZEROES, BLANKS, STRINGS
SORT – OUTPUT DATASET DCB (LRECL,RECFM,BLKSIZE)
SORT – INCLUDE and OMIT
SORT – Process Order of CONTROL Statements
SORT – How to use VB dataset (VLSHRT)
SORT – EDIT MASK PATTERNS
SORT – EDIT NUMERIC FIELDS (I,T,S)
SORT – EDIT FIRST AND LAST RECORD
SORT – SYMBOLS
SORT – TO REPLACE A CHAR WITH ANOTHER CHAR – ALTSEQ
SORT – SET RETURN CODE ‘04’ IF OUTPUT FILE IS EMPTY
SORT – INREC, INCLUDE and OMIT
SORT – SKIPREC and STOPAFT
SORT – INREC
SORT – SUM FIELDS
SORT – REMOVE DUPLICATES AND WRITE THEM TO XSUM
DFSORT – Informational and Error Messages
SORT JOIN – UNPAIRED RECORDS INDICATOR
SORT JOIN – TO JOIN TWO FILES BASED ON A KEY
SORT JOB – SIMPLE COPY
SORT TIPS
Advertisements