MainframeSupports
tip week 36/2003:

For many years it has been possible to change data using DFSORT (also known as ICEMAN or simply SORT), but it is my impression, that this fact is a well kept secret. I will now try and make it public knowledge.

Let me start with an example. The example assumes that the input and output datasets are defined as FB 80 datasets. The following step changes data by using the lookup function in the OUTFIL OUTREC= command.

//MYCHANGE EXEC PGM=SORT
//SORTIN   DD DISP=SHR,DSN=MY.ORIGINAL.DATA
//SORTOUT  DD DISP=SHR,DSN=MY.CHANGED.DATA
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
  SORT FIELDS=COPY
  OUTFIL OUTREC=(1,50,
  51,4,CHANGE=(4,C'0600',C'0700'),
       NOMATCH=(C'0800'),
  55,4,
  59,8,CHANGE=(8,C'SOMENAME',C'OTHRNAME',
                 C'THISNAME',C'OTHRNAME',
                 C'FRANCE03',C'DENMARK0',
       NOMATCH=(59,8),
  67,14)
/*

The syntax above are only permitted using the OUTFIL command in older releases of SORT. In newer releases it is also permitted using the normal OUTREC command. The first CHANGE= changes the text 0600 to 0700 in columns 51-54. If columns 51-54 contains anything else than 0600 the following NOMATCH option changes data to 0800. Without the NOMATCH option SORT will terminate if other values than 0600 turns up. The other CHANGE= shows how to change different values, and the following NOMATCH will take care of all values not mentioned in the list and transfer them unchanged.

You can read a lot more about SORT on IBM's bookmanager DFSORT bookshelf.

Previous tip in english        Sidste danske tip        Tip list