3. The following step demonstrates the look-up function CHANGE. For the below example the input and output data-sets are assumed to be of FB/80.
Code: Select all
//STEP001 EXEC PGM=SORT
//SORTIN DD DISP=SHR,DSN=HLQ.ORIGINAL.INPUT
//SORTOUT DD DISP=SHR,DSN=HLQ.CHANGED.OUTPUT
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC BUILD=(1,10,
56,4,CHANGE=(4,C'0100',C'0200'),
NOMATCH=(C'0999'),
15,4,
55,1,CHANGE=(8,C'A',C'ANUJ',
C'R',C'ROBERT',
C'W',C'WILLIAM',
NOMATCH=(19,1),
27,54,
80:X)
/*
The first CHANGE= changes the text 0100 to 0200 for the data sourced from column 56 for a length of four. The length of the changed field is four bytes (this CHANGE will not increase or decrease the length of the original data). If the existing value is other than 0100 the following NOMATCH option changes all other values to 0999. If NOMATCH is not coded SORT will terminate if a value other than 0100 turns up.
The second CHANGE= shows how to change multiple values and also those of different lengths. One byte of the source record is given a length of 8 in the new BUILD record. Values which are changed but which are shorter than eight in length will be padded with space. The NOMATCH in this case leaves the value from the source unchanged, but pads it with space to a length of eight bytes.
As well as with BUILD, CHANGE can also be used with OVERLAY, but bear in mind that if the length of a field is changed, any data following the source field will be overlayed, so be certain that that is what you want.
From an idea by Anuj.