z/OS DFSORT Application Programming Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Example 13

z/OS DFSORT Application Programming Guide
SC23-6878-00

  OPTION COPY
  OUTREC PARSE=(%01=(ABSPOS=2,FIXLEN=13,ENDBEFR=C'","'),
                %=(ENDBEFR=C'","'),
                %03=(FIXLEN=6,ENDBEFR=C'","'),
                %04=(FIXLEN=6,ENDBEFR=C'","'),
                %05=(FIXLEN=12,ENDBEFR=C'"')),
    BUILD=(%01,20:%03,SFF,ADD,%04,SFF,EDIT=(SIIT.T),SIGNS=(,-),
           31:%05)

This example illustrates how you can reformat records containing variable position/length fields, such as comma separated values.

The 80-byte input records might look like this:
"Buffy Summers","F","+725.8","-27.3","Sunnydale"
"Bruce Wayne","M","-5.3","-173.2","Gotham City"
"Clark Kent","M","+21.3","-15.8","Metropolis"
"Diana Prince","F","-16.4","+128.9","Gateway City"

Note that each record has five variable fields, each enclosed in quotes and separated by a comma. The fields do not start and end in the same position in every record and they have different lengths in different records.

The 42-byte output records should look like this:
Buffy Summers       698.5     Sunnydale
Bruce Wayne        -178.5     Gotham City
Clark Kent            5.5     Metropolis
Diana Prince        112.5     Gateway City
The first fixed-length output field corresponds to the first variable input field. The second fixed-length output field corresponds to the total of the third and fourth variable input fields. The third fixed-length output field corresponds to the fifth variable input field.

In order to reformat the input records for output, we use PARSE and BUILD to create the fixed parsed fields we need from the variable position/length fields; the quotes around each value are removed. %00 is used for the first input field. % is used to ignore the second input field. %03 and %04 are used for the third and fourth input fields which are added together using SFF format. %05 is used for the fifth input field.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014