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

Filter on Date using SORT


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

New User


Joined: 14 Jul 2010
Posts: 13
Location: United States

PostPosted: Tue Oct 19, 2010 8:53 am
Reply with quote

Hi,

I have a flat file with records having a date field (CCYY-MM-DD format).
The file will have data for a particular month (say September) and few records from next month (say October).

I have a monthly Job which will run on every 7th of a month and it needs to process data for the prior month.

In above scenario, on 7th October, I need to process data only for September month. Any records for October should be written to a separate file for next months processing.

Is this something I can achieve through SORT -
If the date field from the input file falls on or in between first or end date of the prior month then write to an output file
If Greater then End date of the prior month, then write off to another file.

Thanks
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Tue Oct 19, 2010 12:15 pm
Reply with quote

Hi,

The below code gives you two files. First file with previous month data & Second file with Current month data.
Code:
//STEP10   EXEC PGM=ICETOOL                       
//*                                               
//TOOLMSG      DD  SYSOUT=*                       
//DFSMSG       DD  SYSOUT=*                       
//*                                               
//I1           DD *                               
2010-09-10                                       
2010-10-02                                       
2010-09-01                                       
2010-10-04                                       
2010-09-10                                       
/*                                               
//*                                               
//M1      DD SYSOUT=*                             
//M2      DD SYSOUT=*                             
//TOOLIN   DD  *    *** CONSTANT CONTROL CARDS ***
  COPY FROM(I1) TO(M1) USING(CTL1)               
/*                                               
//CTL1CNTL DD *                                   
  OUTFIL FNAMES=M1,INCLUDE=(1,7,CH,EQ,DATE2(-)-1)
  OUTFIL FNAMES=M2,INCLUDE=(1,7,CH,EQ,DATE2(-))   
/*                                               

Output File 1(Previous Month data):
Code:
2010-09-10
2010-09-01
2010-09-10

Output File 2 (Current Month data):
Code:
2010-10-02
2010-10-04

Hope this helps you.
Back to top
View user's profile Send private message
SORTQUERY

New User


Joined: 14 Jul 2010
Posts: 13
Location: United States

PostPosted: Wed Oct 20, 2010 12:26 am
Reply with quote

I think this is gonna work for me...I will try this out with my data.
Thanks a lot for the quick response.
Back to top
View user's profile Send private message
SORTQUERY

New User


Joined: 14 Jul 2010
Posts: 13
Location: United States

PostPosted: Wed Oct 20, 2010 2:34 am
Reply with quote

Figured out that the input date layout is not CCYY-MM-DD.
It is MM/DD/CCYY.

I can change the format to CCYYMMDD first, use the date logic and then revert back the date format.

Is there a better way to do it?

Thanks
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Wed Oct 20, 2010 5:29 pm
Reply with quote

Assumed LRECL=80, RECFM=FB. The below JCL will give desire output.
Code:
//STEP10   EXEC PGM=ICETOOL                                   
//*                                                           
//TOOLMSG      DD  SYSOUT=*                                   
//DFSMSG       DD  SYSOUT=*                                   
//*                                                           
//I1           DD *                                           
09/10/2010                                                     
10/02/2010                                                     
09/01/2010                                                     
10/04/2010                                                     
09/10/2010                                                     
/*                                                             
//*                                                           
//M1      DD SYSOUT=*                                         
//M2      DD SYSOUT=*                                         
//TOOLIN   DD  *    *** CONSTANT CONTROL CARDS ***             
  COPY FROM(I1) TO(M1) USING(CTL1)                             
/*                                                             
//CTL1CNTL DD *                                               
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:7,4,6,1,1,5))           
  OUTFIL FNAMES=M1,INCLUDE=(81,7,CH,EQ,DATE2(/)-1),BUILD=(1,80)
  OUTFIL FNAMES=M2,INCLUDE=(81,7,CH,EQ,DATE2(/)),BUILD=(1,80) 
/*                                                             

Hope this helps you.
Back to top
View user's profile Send private message
SORTQUERY

New User


Joined: 14 Jul 2010
Posts: 13
Location: United States

PostPosted: Thu Oct 21, 2010 7:47 pm
Reply with quote

This is better. Thanks Nelson.
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