IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to Sort by Date


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Redrose
Currently Banned

New User


Joined: 06 Mar 2006
Posts: 19

PostPosted: Thu Oct 12, 2006 10:42 am
Reply with quote

Hi All icon_smile.gif ,

Can anyone help me on how to sort by date....

My input file has the date format 'MM/DD/YY' E.g., '09/30/06'


Thanks & Regards,
Ramanan R
Back to top
View user's profile Send private message
mubs55

New User


Joined: 19 Apr 2006
Posts: 12

PostPosted: Thu Oct 12, 2006 11:25 am
Reply with quote

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

then just extend the sort to 8 bytes
/*
Back to top
View user's profile Send private message
Redrose
Currently Banned

New User


Joined: 06 Mar 2006
Posts: 19

PostPosted: Thu Oct 12, 2006 11:56 am
Reply with quote

Hi mubs55,

Thanks for your quick response. If you don't mind can you explain what the SYSIN card parameters do.

I checked with the document, i don't understand. Please advice...

Thanks & Regards,
Ramanan R
Back to top
View user's profile Send private message
mubs55

New User


Joined: 19 Apr 2006
Posts: 12

PostPosted: Thu Oct 12, 2006 12:25 pm
Reply with quote

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
Back to top
View user's profile Send private message
naveen.prabhu.p

New User


Joined: 20 Sep 2006
Posts: 4
Location: Bangalore

PostPosted: Thu Oct 12, 2006 12:28 pm
Reply with quote

If you can interpret what Mubs has given,
The input format she mentioned shows pos
5,2 MM
8,2 DD
11,2 YY

you'll have to use your date fields correctly from input file.
I checked out, the above sort it works...

Cheers,
Naveen
Back to top
View user's profile Send private message
Redrose
Currently Banned

New User


Joined: 06 Mar 2006
Posts: 19

PostPosted: Thu Oct 12, 2006 12:44 pm
Reply with quote

Thanks a lot for your detailed description, I got it icon_biggrin.gif .

But my requirement is for 'MMDDYY'. I guess, i need to code the OVERLAY parameter as below,

INREC OVERLAY=(81:8,2,83:5,2,85:11,2)

Will 'Y2W' Sort option work for the above INREC. Thanks.

Regards,
Ramanan R
Back to top
View user's profile Send private message
mubs55

New User


Joined: 19 Apr 2006
Posts: 12

PostPosted: Thu Oct 12, 2006 2:50 pm
Reply with quote

Sort provided by me was meant for mmddyy.
please use the same inrec as i have provided earlier
Back to top
View user's profile Send private message
Redrose
Currently Banned

New User


Joined: 06 Mar 2006
Posts: 19

PostPosted: Thu Oct 12, 2006 3:28 pm
Reply with quote

Naveen,
Thanks for the information....

Mubs,
Thanks for your help....

Regards,
Ramanan R
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Oct 12, 2006 9:33 pm
Reply with quote

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.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top