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
 

 

How to select the latest date record From VSAM file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
rohanatl

New User


Joined: 21 Oct 2005
Posts: 22

PostPosted: Fri Dec 16, 2011 5:17 pm    Post subject: How to select the latest date record From VSAM file
Reply with quote

I have the following requirement.
Need to select the record with the latest date from a vsam file.
For Eg: I/p file is having the records like
Item Vendor Number Receipt Date
428 101 121225 (YYMMDD)
428 102 121223
In the above case i need to select the first record (with date 121225) since it is having the latest receipt date. Please help!
Back to top
View user's profile Send private message

PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Fri Dec 16, 2011 5:23 pm    Post subject:
Reply with quote

If its a KSDS try an AIX on the receipt date. Probably you will have a lot of duplicates (maybe too much to build an aix).
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Dec 16, 2011 5:23 pm    Post subject:
Reply with quote

if it is as simple as extracting the latest date for each item/vendor number,
there are many sort solutions available,
which would be easier/quicker to code and implement than a cobol module.

either way, you still need to sort the data before determining which record to keep.
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 110
Location: Puerto Rico

PostPosted: Fri Dec 16, 2011 7:48 pm    Post subject:
Reply with quote

Good day to all!

I agree with dbz.., you should sort the file in descending order by date that way you will be processing the latest date first.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Sat Dec 17, 2011 3:32 am    Post subject:
Reply with quote

Hi,

the solutions provided are fine but I don't believe a sort is a must.

You can read and compare each record to the previous record and retain the record with the latest date.

Continue this process till the EOF and wrtite out the one with the latest date.


Gerry
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts Underlying DB2 VSAM LDS - SMF recording vasanthz All Other Mainframe Topics 6 Thu Jan 05, 2017 4:20 am
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm


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