View previous topic :: View next topic
Author
Message
jaganmoni1 New User Joined: 31 Oct 2008Posts: 35 Location: CANADA
I have a FB file and the LRECL is 80 bytes. I want to sort this file using date value. The date value (MMDDYY) is from column 4 to 9.
Could you please tell me how to sort date value using SYNCSORT?
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Code:
SORT FIELDS=(8.2.CH.A.4.2.CH.A.6.2.CH.A)
You can always take the CHs out by using FORMAT=CH outside the brackets.
or
Code:
//SYMNAMES DD *
DATE-YEAR,8,2,CH,A
DATE-MONTH,4,2,CH,A
DATE-DAY,6,2,CH,A
//SYSIN DD *
SORT FIELDS=(DATE-YEAR,DATE-MONTH,DATE-DAY)
It is much more typing, I know, but it gives you (and future maintainers) a much better idea of what is happening.
Is this your first Sort?
EDIT: swapped the DD/MM around....
Back to top
jaganmoni1 New User Joined: 31 Oct 2008Posts: 35 Location: CANADA
Hi Bill,
Thank you very much for your quick response. The problem is the year might be from 80 (1980) to 11 (2011). Is there any way to convert year from YY to YYYY before sorting?
I mean if YY is >79 then YYYY is 19YY else 20YY.
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
this should help
Code:
//STEP001 EXEC PGM=SORT
//SORTIN DD *
010280
122712
061511
/*
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(81,8,BI,A)
INREC IFTHEN=(WHEN=(8,2,ZD,GT,79),
OVERLAY=(81:C'19',8,2,4,2,6,2)),
IFTHEN=(WHEN=NONE,
OVERLAY=(81:C'20',8,2,4,2,6,2))
/*
Gerry
Back to top
kratos86 Active User Joined: 17 Mar 2008Posts: 148 Location: Anna NGR
If you have SYNCSORT version 1.3 and above, use this one -
Code:
SORT FIELDS=(1,6,Y2W,A),CENTWIN=80
Back to top
Please enable JavaScript!