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


Example 31

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

  OPTION Y2PAST=1990                                                 
  SORT FIELDS=(1,6,Y2W,A)                                            
  OUTFIL REMOVECC,                                                   
     HEADER1=(1:'Input',15:'NEXTDFRI',25:'PREVDSUN',35:'LASTDAYQ'),  
     BUILD=(1:1,6,Y2W,TOJUL=Y4W(-),                                  
           15:1,6,Y2W,NEXTDFRI,TOJUL=Y4W(-),                         
           25:1,6,Y2W,PREVDSUN,TOJUL=Y4W(-),                         
           35:1,6,Y2W,LASTDAYQ,TOJUL=Y4W(-))

This example illustrates how you can sort by a date, and calculate a specific day after and before a date, and the last day of the quarter for a date. The input date is in the form C'mmddyy' and the output dates will be in the form 'ddd-yyyy'.

The SORTIN data set has these input records with a C'mmddyy' date field in positions 1-6:
010105
120699
021610
999999
092810
031500
000000
032505
110210

The SORT statement sorts by the C'mmddyy' date. We use 1,6,Y2W for the sort field to match the C'mmddyy' date.

The OUTFIL statement writes a heading and performs four operations on each date. It converts the input date to C'ddd-yyyy' form, gets the next Friday date in C'ddd-yyyy' form, gets the previous Sunday date in C'ddd-yyyy' form, and gets the end of the quarter date in C'ddd-yyyy' form. We use 1,6,Y2W for the input field to match the C'mmddyy' date, and we use TOJUL=Y4W(-) to give us a C'ddd-yyyy' output date.

SORTOUT will have these records:
Input         NEXTDFRI  PREVDSUN  LASTDAYQ
000-0000      000-0000  000-0000  000-0000
340-1999      344-1999  339-1999  365-1999
075-2000      077-2000  072-2000  091-2000
001-2005      007-2005  361-2004  090-2005
084-2005      091-2005  079-2005  090-2005
047-2010      050-2010  045-2010  090-2010
271-2010      274-2010  269-2010  273-2010
306-2010      309-2010  304-2010  365-2010
999-9999      999-9999  999-9999  999-9999

Note that the '000000' and '999999' input values are treated as special indicators for output.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014