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 Last month records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Filter Last month records
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Nov 02, 2011 2:31 pm    Post subject: Reply to: Filter Last month records
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Nov 02, 2011 3:12 pm    Post subject: Reply to: Filter Last month records
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Nov 02, 2011 3:31 pm    Post subject: Reply to: Filter Last month records
Reply with quote

see here where a similar requirement is solved
http://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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Nov 02, 2011 4:49 pm    Post subject: Reply to: Filter Last month records
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Nov 02, 2011 5:33 pm    Post subject: Reply to: Filter Last month records
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    Post subject:
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

Site Director


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

PostPosted: Wed Nov 02, 2011 7:54 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
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 How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm


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