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:
And you want to your output to be as below:
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.
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|