View previous topic :: View next topic
|
Author |
Message |
ratnakumar
New User
Joined: 07 May 2009 Posts: 30 Location: Banglore
|
|
|
|
Hello,
I have a requirement, If I submit a job today, I need to get records for last month from a flat file.
i.e If I submit the job today(Nov-2), I need to get the records only for Oct-2011
sample VB file with record length = 80.
-----------------------------------------------
20110121 ABCDE
20111008 ABCDE
20111030 ABCDE
20110113 ABCDE
20110212 ABCDE
20110515 ABCDE
20110830 ABCDE
20110922 ABCDE
20110123 ABCDE
20111015 ABCDE
Desired output:
-----------------
20111008 ABCDE
20111030 ABCDE
20111015 ABCDE
I tried using SORT, Include condition with DATE2-1 but its not working for me.. Can anyone please provide me the solution.
Regards,
Ratna |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Show your sort cards tried, sort product used, sample of input data, output achieved and output expected. In the Code tags, please. |
|
Back to top |
|
|
ratnakumar
New User
Joined: 07 May 2009 Posts: 30 Location: Banglore
|
|
|
|
Code: |
//STEP01A EXEC PGM=SORT
//SORTIN DD DSN=Inpuit file,DISP=SHR
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=OUT file,
// DISP=(NEW,CATLG,DELETE), ...
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(5,8,CH,EQ,DATE2-1)
//* |
This is what I used. Please help me out. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
So I'm not going to check the format of DATE2, I can just tell that it cannot both be 8 characters long and such that subtract one from it represents one month, can it?
You're missing out the file information still.... |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
ratnakumar
New User
Joined: 07 May 2009 Posts: 30 Location: Banglore
|
|
|
|
@ Bill
-------
Code: |
SORT FIELDS=COPY
INCLUDE COND=(5,6,CH,EQ,DATE2-1)
//*
|
I changed the 8 characters lenght to 6 and it worked .
And I am worried that would it work when the jobs runs in production on Jan2012 ?
I mean when the job runs on Jan2012, would it pull the records for Dec-2011 ?
- Ratna |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
That's why you have test data....
What about when you have to re-run the thing in production for some reason? Like you run it in June, to reproduce May's data?
I'd say better to use a Business Date, from a file, than the system date.
Turns out to be easier to test as well. |
|
Back to top |
|
|
ratnakumar
New User
Joined: 07 May 2009 Posts: 30 Location: Banglore
|
|
|
|
Ya True. Its good to use the business date, but I feel INCLUDE sort is easier way to retrieve data with simple logic.
I learnt that DATE2 operand will take care even if there is a change in year.... we can use DATE2-2, DATE2-3.....DATE2-12 to get previous months or previous years data. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, that just leaves you with changing the SORT when you want to do a re-run (better put it in the run instructions).
If you have a search in the forum you'll find some examples of taking a date off a file, generating a SYMNAME for that date, and then using the SYMNAME in the sort processing, including include. That way, you can have your cake and eat it. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
posted,
obviously,
after Bill has made the same piont.
but i want to say it also, just other words.
ratnakumar wrote: |
but I feel INCLUDE sort is easier way to retrieve data with simple logic. |
a common attribute of you self-centered, less-than-adequate skill-set'ed rookies,
is that you miss the point.
nobody said anything about the INCLUDE.
what was suggested by someone who apparently has light-years more experience and beyond the end-of-your-nose analytical capababilites than you,
is that you will never be able to rerun a prior months work without changing your sort control cards,
whereas if you control the date from an outside source,
i.e. contained in a file, input to a separate step to be used in sysnames,
you need never change your JCL.
but you have your answer,
and hopefully,
i have not invested in a company that employs you or one that your site services. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Its good to use the business date, but I feel INCLUDE sort is easier way to retrieve data with simple logic. |
What utter nonsense. . . The programmer's "feelings" (i.e. programmer preference) should have nothing to do with the implementation for meeting the business requirement.
The process needs to be implemented so that it meets the business rules for every situation, whether this is the method the programmer likes better or not. |
|
Back to top |
|
|
|