|
View previous topic :: View next topic
|
| Author |
Message |
SORTQUERY
New User
Joined: 14 Jul 2010 Posts: 13 Location: United States
|
|
|
|
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 |
|
 |
nelson.pandian
Active User
.jpg)
Joined: 09 Apr 2008 Posts: 133 Location: Phoenix, AZ
|
|
|
|
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 |
|
 |
SORTQUERY
New User
Joined: 14 Jul 2010 Posts: 13 Location: United States
|
|
|
|
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 |
|
 |
SORTQUERY
New User
Joined: 14 Jul 2010 Posts: 13 Location: United States
|
|
|
|
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 |
|
 |
nelson.pandian
Active User
.jpg)
Joined: 09 Apr 2008 Posts: 133 Location: Phoenix, AZ
|
|
|
|
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 |
|
 |
SORTQUERY
New User
Joined: 14 Jul 2010 Posts: 13 Location: United States
|
|
|
|
| This is better. Thanks Nelson. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|