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

How to sort the records based on the date field?


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

New User


Joined: 04 Oct 2005
Posts: 34

PostPosted: Wed Jul 04, 2012 3:41 pm
Reply with quote

How to sort the records by using Date field?
Iput file have a thousand of records like following formation.

Client Number (1 to 21)
Information Number (22 to 41)
Card number (42 to 61)
Date(62 to 8)
Status (70 to 79)
Indicator(80 to 81)

Code:

Input file:
--------------
130295318            451XXXXXX2953185     451XXXXXXX031765   20120118 06  0
230304839            451XXXXXX3048399     451XXXXXXX051631   20120123 06  1
230304839            451XXXXXX3048399     451XXXXXXX019315   20120123 06  0
230304839            451XXXXXX3048399     451XXXXXXX019315   20120123 08  1
230304839            451XXXXXX3048399     451XXXXXXX022150   20120123 08  0
230304839            451XXXXXX3048399     451XXXXXXX022150   00000000 10  2
430305844            451XXXXXX3058448     451XXXXXXX068155   20120508 08  0
130907789            451XXXXXX9077897     451XXXXXXX014514   20111221 10  0
230907789            451XXXXXX9077897     451XXXXXXX018812   20120113 06  0
330907789            451XXXXXX9077897     451XXXXXXX018812   00000000 10  0
430907789            451XXXXXX9077897     451XXXXXXX010892   20111221 08  1
530907789            451XXXXXX9077897     451XXXXXXX010892   20111222 06  0
.
.
.
.
.

Code:
output file 1:
---------------

130295318            451XXXXXX2953185     451XXXXXXX031765   20120118 06  0
.
.
.


Code:
output file 2:
--------------

230304839            451XXXXXX3048399     451XXXXXXX019315   20120123 06  0
130907789            451XXXXXX9077897     451XXXXXXX010892   20111222 06  0.
.
.
.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 04, 2012 7:46 pm
Reply with quote

Code:
  SORT FIELDS=(62,8,CH,A)


If that is not what you want, you have to provide all the information. Haven't a clue how you want the data selected/split.
Back to top
View user's profile Send private message
naveensrimf

New User


Joined: 04 Oct 2005
Posts: 34

PostPosted: Thu Jul 05, 2012 1:26 pm
Reply with quote

All Records are sorted based on dates. If First record and Second Record date fileds are equal then latest datefield record need to write into a output file1 and rest of all records need to write into a output file2.

Eg:

Code:
Input file:
----------
230304839 451XXXXXX3048399 451XXXXXXX051631 20120123 06 1
230304839 451XXXXXX3048399 451XXXXXXX051631 20120123 06 1
230304839 451XXXXXX3048399 451XXXXXXX019315 20120122 08 1
230304839 451XXXXXX3048399 451XXXXXXX022150 20120122 08 0
230304839 451XXXXXX3048399 451XXXXXXX022150 00000000 10 2

Code:
output file1:
------------
230304839 451XXXXXX3048399 451XXXXXXX051631 20120123 06 1

Code:
Output file2:
--------------
230304839 451XXXXXX3048399 451XXXXXXX051631 20120123 06 1
230304839 451XXXXXX3048399 451XXXXXXX019315 20120122 08 1
230304839 451XXXXXX3048399 451XXXXXXX022150 20120122 08 0
230304839 451XXXXXX3048399 451XXXXXXX022150 00000000 10 2
Back to top
View user's profile Send private message
naveensrimf

New User


Joined: 04 Oct 2005
Posts: 34

PostPosted: Thu Jul 05, 2012 1:44 pm
Reply with quote

Latest date record is not first record. See below example with more records

Code:
Input file:
----------
230304839 451XXXXXX3048399 451XXXXXXX051631 20120123 06 1
230304839 451XXXXXX3048399 451XXXXXXX051632 20120123 06 1
230304839 451XXXXXX3048399 451XXXXXXX019315 20120122 08 1
230304839 451XXXXXX3048399 451XXXXXXX022150 20120122 08 0
230304839 451XXXXXX3048399 451XXXXXXX022151 00000000 10 2

230304840 451XXXXXX3048340 451XXXXXXX051631 20120123 06 1
230304840 451XXXXXX3048340 451XXXXXXX051632 20120124 06 1
230304860 451XXXXXX3048360 451XXXXXXX019313 20120123 08 1
230304860 451XXXXXX3048360 451XXXXXXX022154 20120125 08 0
230304870 451XXXXXX3048370 451XXXXXXX022155 00000000 10 2

Code:
output file1:
------------
230304839 451XXXXXX3048399 451XXXXXXX051631 20120123 06 1
230304840 451XXXXXX3048340 451XXXXXXX051632 20120124 06 1
230304860 451XXXXXX3048360 451XXXXXXX022154 20120125 08 0


Code:
output file2:
--------------
230304839 451XXXXXX3048399 451XXXXXXX051632 20120123 06 1
230304839 451XXXXXX3048399 451XXXXXXX019315 20120122 08 1
230304839 451XXXXXX3048399 451XXXXXXX022150 20120122 08 0
230304839 451XXXXXX3048399 451XXXXXXX022151 00000000 10 2

230304840 451XXXXXX3048340 451XXXXXXX051631 20120123 06 1
230304860 451XXXXXX3048360 451XXXXXXX019313 20120123 08 1
230304870 451XXXXXX3048370 451XXXXXXX0221505 00000000 10 2
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 05, 2012 10:31 pm
Reply with quote

naveensrimf,

Your near-duplicate topic has now been deleted.

Have you looked at possibilities with ICETOOL? Have you consulted the Smart DFSORT Tricks publication?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Jul 05, 2012 11:21 pm
Reply with quote

naveensrimf,

Assuming you wanted to sort on the Client number and get the latest date record, you can use the following DFSORT/ICETOOL JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//IN       DD DSN=Your Input file,DISP=SHR                                       
//OUT1     DD SYSOUT=*                                               
//OUT2     DD SYSOUT=*                                               
//TOOLIN   DD *                                                       
  SELECT FROM(IN) TO(OUT1) ON(1,21,CH) FIRST DISCARD(OUT2) USING(CTL1)
//*                                                                   
//CTL1CNTL DD *                                                       
  SORT FIELDS=(1,21,CH,A,62,8,CH,D)                                   
//*                     


OUT1 will have
Code:

230304839            451XXXXXX3048399    451XXXXXXX051631    2012012306        1
230304840            451XXXXXX3048340    451XXXXXXX051632    2012012406        1
230304860            451XXXXXX3048360    451XXXXXXX022154    2012012508        0
230304870            451XXXXXX3048370    451XXXXXXX022155    0000000010        2


OUT2 will have
Code:

230304839            451XXXXXX3048399    451XXXXXXX051632    2012012306        1
230304839            451XXXXXX3048399    451XXXXXXX019315    2012012208        1
230304839            451XXXXXX3048399    451XXXXXXX022150    2012012208        0
230304839            451XXXXXX3048399    451XXXXXXX022151    0000000010        2
230304840            451XXXXXX3048340    451XXXXXXX051631    2012012306        1
230304860            451XXXXXX3048360    451XXXXXXX019313    2012012308        1
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
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
Search our Forums:

Back to Top