CHANGE in OUTREC statement can be used to look up and change the content in the file while sorting. Build parameter is used to reformat records. Build give complete control over output file format. BUILD parameter can be used on INREC and OUTREC statements in SORT card. BUILD parameter is an alias of the FIELDS parameter. Build parameter can be used in OUTFIL statement also.
OUTREC FIELDS=(Starting position of field1,Length of field1, CHANGE=(v,find,set,.),.) OUTREC BUILD=(Starting position of field1, Length of field1, CHANGE=(v,find,set,…),…)
NOMATCH can be used to change if no match is found with any of the constants in the table. NOMATCH=(set) to set the output value when an input field value does not match any of the find constants.
NOMATCH=(C'string') sets a character string constant. NOMATCH=(X'string') sets a hexadecimal string constant. NOMATCH=(q,n) sets an input field value.
Name | Description |
Starting position of field1 | Specifies field1 starting position in the input file after sorting. |
Length of feild1 | Field1 physical length in input file. |
V | Specifies the length of the output field |
Find | Table consisting pairs of find constants |
Set | Set constants or set fields |
Input data on the Employee & Month of Joining.
EMP NO (1:10) | NAME (11:20) | MONTH (31:3) |
1 | Cheryl | JAN |
2 | Norman | MAR |
3 | Leonaid | DEC |
4 | Ian | OCT |
5 | Linda | FEB |
This example illustrates how Name can be converted to Upper Case & how values in a text field can be changed to another text using a lookup table using BUILD.
//STEP001 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DSN=XXXXX.YYYYY.INPUT,DISP=SHR //SORTOUT DD DSN= XXXXX.YYYYY.OUTPUT, // DISP=(NEW,CATLG,DELETE),UNIT=3390, // SPACE=(CYL,(5,1)),DCB=(LRECL=22) //SYSIN DD * //SYSIN DD * SORT FIELDS=COPY OUTREC BUILD=(1,30,TRAN=LTOU,31,3, - CHANGE=(10, - C'JAN',C'JANUARY', - C’FEB',C'FEBRUARY', - C'MAR',C'MARCH', - C'APR',C'APRIL', - C'MAY',C'MAY', - C'JUN',C'JUNE', - C'JUL',C'JULY', - C'AUG',C'AUGUST', - C'SEP',C'SEPTEMBER', - C'OCT',C'OCTOBER', - C'NOV',C'NOVEMBER', - C'DEC',C'DECEMBER'), - NOMATCH=(31,3)) /*
Explanation –
This sort card will copy first 30 bytes from input file & convert all letter to upper case letters. 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 previous OUTREC statement:
Data at 31st position of the input file (3 bytes) will be compared with the data provided in CHANGE list. if any match found in the list corresponding data will be moved to output file e.g.whenever the month contains ‘JAN’, the output field is set to ‘JANUARY’. Whenever the month contains ‘FEB’, the output field is set to ‘FEBRUARY’, and so on.
The results produced for this OUTREC statement are:
EMP NO (1:10) | NAME (11:20) | MONTH (31:10) |
1 | CHERYL | JANUARY |
2 | NORMAN | MARCH |
3 | LEONAID | DECEMBER |
4 | IAN | OCTOBER |
5 | LINDA | FEBRURARY |
EMP NO (1:10) | NAME (11:20) | MONTH (31:3) | SUBJECT (35:5) |
1 | Cheryl | JAN | ENGL |
2 | Norman | MAR | BUSIN |
3 | Leonaid | DEC | COMP |
4 | Ian | OCT | HIST |
5 | Linda | FEB | PSYCH |
This example illustrates how Name can be converted to Upper Case & how values in two text fields can be changed to other text using a lookup table.
//STEP001 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DSN=XXXXX.YYYYY.INPUT,DISP=SHR //SORTOUT DD DSN= XXXXX.YYYYY.OUTPUT, // DISP=(NEW,CATLG,DELETE),UNIT=3390, // SPACE=(CYL,(5,1)),DCB=(LRECL=22) //SYSIN DD * //SYSIN DD * SORT FIELDS=COPY OUTREC FIELDS=(1,30,TRAN=LTOU, 31,3,CHANGE=(10, C'JAN',C'JANUARY', C’FEB',C'FEBRUARY', C’MAR',C'MARCH', C'APR',C'APRIL', C'MAY',C'MAY', C'JUN',C'JUNE', C'JUL',C'JULY', C'AUG',C'AUGUST', C’SEP',C'SEPTEMBER C'OCT',C'OCTOBER', C'NOV',C'NOVEMBER', C'DEC',C'DECEMBER' NOMATCH=(C’UNDIFINED’), 35,5,CHANGE=(20, C'HIST',C'HISTORY', C'BUSIN',C'BUSINESS' C'COMP',C'COMPUTER SCIENCE', C'ENGL',C'ENGLISH', C’BIOL’,C'BIOLOGY', C'PSYCH',C'PSYCHOLOGY'), NOMATCH=(C’UNAFFILIATED’)) /*
Explanation –
This sort card will copy first 30 bytes from input file & convert all letter to upper case letters. 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 previous OUTREC statement:
Data at 31st position of the input file (3 bytes) will be compared with the data provided in CHANGE list. if any match found in the list corresponding data will be moved to output file e.g.whenever the month contains ‘JAN’, the output field is set to ‘JANUARY’. Whenever the month contains ‘FEB’, the output field is set to ‘FEBRUARY’, and so on.
The results produced for this OUTREC statement are:
EMP NO (1:10) | NAME (11:20) | MONTH (31:3) | SUBJECT (35:5) |
1 | CHERYL | JANUARY | ENGLISH |
2 | NORMAN | MARCH | BUSINESS |
3 | LEONAID | DECEMBER | COMPUTER |
4 | IAN | OCTOBER | HISTORY |
5 | LINDA | FEBRURARY | PHYSICS |
This example illustrates how a sequence number can be generated, how values in one numeric or date format can be converted to another format, and how a lookup table can be used.
OPTION COPY,Y2PAST=1985 INREC FIELDS=(SEQNUM,4,BI, 8,5,ZD,TO=PD, 31,2,PD,TO=FI,LENGTH=2, 15,6,Y2TP,25,3, CHANGE=(1,C'L92',X'01',C'M72',X'02',C'J42',X'03'), NOMATCH=(X’FF’))
Explanation –
The reformatted input records will look as follows:
The SORT statement can now refer to the “sort” field in the reformatted input records. The OUTREC statement is used to restore the records to their original format.
A well-maintained product backlog is crucial for successful product development. It serves as a single…
Incremental value to the customer refers to the gradual delivery of small, functional parts of…
A Product Market refers to the group of potential customers who might be interested in…
The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…
The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…
Choosing the right Scrum Master Certification depends on your current experience and career goals. If…