IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Filter Last month records


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ratnakumar

New User


Joined: 07 May 2009
Posts: 30
Location: Banglore

PostPosted: Wed Nov 02, 2011 2:19 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 02, 2011 2:31 pm
Reply with quote

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
View user's profile Send private message
ratnakumar

New User


Joined: 07 May 2009
Posts: 30
Location: Banglore

PostPosted: Wed Nov 02, 2011 3:06 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 02, 2011 3:12 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Nov 02, 2011 3:31 pm
Reply with quote

see here where a similar requirement is solved
www.ibmmainframes.com/viewtopic.php?t=56423&highlight=date2
Back to top
View user's profile Send private message
ratnakumar

New User


Joined: 07 May 2009
Posts: 30
Location: Banglore

PostPosted: Wed Nov 02, 2011 4:32 pm
Reply with quote

@ 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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 02, 2011 4:49 pm
Reply with quote

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
View user's profile Send private message
ratnakumar

New User


Joined: 07 May 2009
Posts: 30
Location: Banglore

PostPosted: Wed Nov 02, 2011 5:27 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 02, 2011 5:33 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Nov 02, 2011 5:39 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Nov 02, 2011 7:54 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top