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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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