View previous topic :: View next topic
Author
Message
mistah kurtz Active User Joined: 28 Jan 2012Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
Hi,
I have a requirement. There is an Input File, which has dates in two formats: YYYY-MM-DD and Julian Date in Packed Decimal format.
Code:
000001 2013-11-22 %
FFFF6FF6FF2136
2013011022032C
---------------------
000002 2013-11-21 *
FFFF6FF6FF2135
2013011021032C
---------------------
000003 2013-11-20 <
FFFF6FF6FF2134
2013011020032C
---------------------
000004 2013-11-19
FFFF6FF6FF2133
2013011019032C
---------------------
000005 2013-11-18
FFFF6FF6FF2132
2013011018032C
In my output I want first three dates which are greater than or equal to the Current Date in MMDDYY format, concatenated as a single string, i.e.
Currently I'm doint it in two pass: first Step to SORT the dates and then Next step to concatenate the first three in single String.
1st Step:
Code:
//SYSIN DD *
SORT FIELDS=(11,4,PD,A)
OUTFIL INCLUDE=(11,4,PD,GE,DATE3P),
BUILD=(1:3,2,3:6,2,5:9,2)
2nd Step:
Code:
//SORTIN DD *
131118
131119
131120
131121
131122
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY,STOPAFT=3
INREC IFTHEN=(WHEN=INIT,OVERLAY=(7:SEQNUM,3,ZD)),
IFTHEN=(WHEN=INIT,OVERLAY=(10:7,3,ZD,MOD,+3,EDIT=(T))),
IFTHEN=(WHEN=GROUP,END=(10,1,ZD,EQ,0),PUSH=(11:ID=1)),
IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,1),PUSH=(15:1,6)),
IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,2),PUSH=(21:1,6)),
IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,0),PUSH=(27:1,6))
OUTFIL INCLUDE=(10,1,ZD,EQ,0),BUILD=(1:15,18)
All the files are LRECL=80,RECFM=FB.
I'm using SYNCSORT. Is there any way to achieve it in single pass or more efficient than the way I'm doing it now?
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
How many records can be on the file? Can it have duplicate dates?
Your second step only reads three records. Not so heavy :-)
The resource-hogger is the SORT.
First, you should always OMIT/INCLUDE to get rid of stuff you are not going to need before the SORT (or other processing).
To look at getting rid of the SORT, be aware that BEGIN can be more complex than you have used. You have something working, so can spend a little time thinking and experimenting.
I would start with storing the date from the record in three places. Then each record can be tested against closest, next closest, last closest.
In OUTFIL, you can use NODETAIL,REMOVECC and TRAILER1 to write something only at the end of the OUTFIL.
Back to top
mistah kurtz Active User Joined: 28 Jan 2012Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
No of records would be around 15000 at max. No It will not have duplicates.
Back to top
mistah kurtz Active User Joined: 28 Jan 2012Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
Quote:
First, you should always OMIT/INCLUDE to get rid of stuff you are not going to need before the SORT (or other processing).
I have changed my first step. I guess this is what you've suggested.
Code:
INCLUDE COND=(11,4,PD,GE,DATE3P)
SORT FIELDS=(11,4,PD,A)
OUTREC BUILD=(1:3,2,3:6,2,5:9,2)
Back to top
mistah kurtz Active User Joined: 28 Jan 2012Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
I have changed the 2nd step as:
Code:
OPTION COPY,STOPAFT=3
INREC IFTHEN=(WHEN=INIT,OVERLAY=(7:SEQNUM,3,ZD)),
IFTHEN=(WHEN=INIT,OVERLAY=(10:7,3,ZD,MOD,+3,EDIT=(T))),
IFTHEN=(WHEN=GROUP,END=(10,1,ZD,EQ,0),PUSH=(11:ID=1)),
IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,1),PUSH=(15:1,6)),
IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,2),PUSH=(21:1,6)),
IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,0),PUSH=(27:1,6))
OUTFIL REMOVECC,NODETAIL,TRAILER1=(1:15,18)
Quote:
be aware that BEGIN can be more complex than you have used.
I didn't quite understand what you are implying by this.
Back to top
Please enable JavaScript!