Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to Sort by Date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How to Sort by Date
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    Post subject: Re: How to Sort by Date
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    Post subject:
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    Post subject: Re: How to Sort by Date
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    Post subject: Hi Ramanan
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    Post subject:
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    Post subject: Re: How to Sort by Date
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    Post subject:
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 Moderator


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

PostPosted: Thu Oct 12, 2006 9:33 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us