Hi,
if your file is
abc 01/20/06
bca 10/01/06
def 02/01/06
The below sort will work only if u have the same century in all the records
//SORT01 EXEC PGM=SORT
//SORTIN DD DSN=INPUT FILE,DISP=SHR (80 byte file)
//SORTOUT DD DSN=OUTPUT FILE,DISP=OLD (80 byte file)
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
INREC OVERLAY=(81:5,2,83:8,2,85:11,2)
SORT FIELDS=(81,6,Y2W,A)
if you want to include century also in ur file then
abc 01/20/2006
bca 10/01/1993
The sort fields=(81,6,y2w,a) is used for sorting the year in the format
ddmmyy
since your request is to sort the format dd/mm/yy we need to remove the slashes temporarily.
Since the length of input and output is 80 bytes, starting from 81st byte will be considered as temp bytes
i have reformated the date field as required starting at 81st position
inrec overlay=(81:5,2,83:8,2...)
this statement will overlay the dd at position 5 to 81 position so on
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
The correct DFSORT job is:
Code:
//SORT01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
* Set century window appropriately
OPTION Y2PAST=1980
* Convert 'mm/dd/yy' to 'mmddyy' in 81-86
INREC OVERLAY=(81:5,2,83:8,2,85:11,2)
* Sort on 'mmddyy' as 'yyyymmdd'
SORT FIELDS=(81,6,Y2W,A)
* Remove 'mmddyy'
OUTREC BUILD=(1,80)
Alternatively, you could use the following INREC statement to handle the conversion of 'mm/dd/yy' to 'mmddyy' more directly:
Code:
INREC OVERLAY=(81:5,8,UFF,EDIT=(TTTTTT))
p,6,Y2T is for a yymmdd date. p,6,Y2W is for an mmddyy date.
DFSORT's Y2x formats can handle dates in two different centuries using the century window. For example, Y2PAST=1980 would set the century window for 1980-2079. Y2PAST=1935 would set the century window for 1935-2034. Y2PAST=2000 would set the century window for 2000-2099, etc. DFSORT's default for Y2PAST is 80 which would set the century window 80 years in the past which this year (2006) would be 1926-2025 and next year would be 1927-2026.