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


Example 7

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

  INREC OVERLAY=(16:1,15,JFY=(SHIFT=LEFT))
  SORT FIELDS=(16,15,CH,A)
  OUTREC BUILD=(1,15)

This example illustrates how you can left-justify characters in an input field so they can be sorted without regard to the leading blanks.

The 15-byte input records might look like this:
   CARRIE
       VICKY
          FRANK
      SAM
DAVID
    MARTIN
Note that if we sort these records using just this control statement:
   SORT FIELDS=(1,15,CH,A)
The 15-byte output records are as follows:
          FRANK
       VICKY
      SAM
    MARTIN
   CARRIE
DAVID
Because of the different number of leading blanks in the input records, we don't get what we want. To fix that, while keeping the leading blanks in the original records, we use the JFY function of INREC to make a left-justified copy of the 15-byte input field at positions 16-30, SORT on it and use OUTREC to remove the left-justified field. With the INREC, SORT and OUTREC control statements shown previously, the output records are:
   CARRIE
DAVID
          FRANK
    MARTIN
      SAM
       VICKY
If we wanted the output to contain the sorted left-justified fields, we could use these control statements:
  INREC BUILD=(1,15,JFY=(SHIFT=LEFT))
  SORT FIELDS=(1,15,CH,A)
The output records would then be:
CARRIE
DAVID
FRANK
MARTIN
SAM
VICKY

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014