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 the records based on the date field?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
naveensrimf

New User


Joined: 04 Oct 2005
Posts: 31

PostPosted: Wed Jul 04, 2012 3:41 pm    Post subject: How to sort the records based on the date field?
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7306

PostPosted: Wed Jul 04, 2012 7:46 pm    Post subject:
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: 31

PostPosted: Thu Jul 05, 2012 1:26 pm    Post subject:
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: 31

PostPosted: Thu Jul 05, 2012 1:44 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7306

PostPosted: Thu Jul 05, 2012 10:31 pm    Post subject:
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    Post subject:
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    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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm


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