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:
- The input field starts in position 1.
- The length of the input field and find constants is 5.
- The length of the output field and set constants is 10.
- The first find constant is ‘DD’ (padded with a blank at the end to 5 characters).
- 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.
——————————————————————————————————–
In United States, If you would like to Earn Free Stocks, Credit card Points and Bank account Bonuses, Please visit My Finance Blog
——————————————————————————————————–
You may also like to look at:
Working on Mainframes – Is Change to a different technology necessary |
Pingback: SORT – PARSE – READ EXCEL (CSV) FILE IN MAINFRAMES | F1 for Mainframe