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
 

 

Filter on Date using SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Filter on Date using SORT
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm


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