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

How to select the latest date record From VSAM file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Dec 16, 2011 5:23 pm
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
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: 121
Location: Puerto Rico

PostPosted: Fri Dec 16, 2011 7:48 pm
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: 1702
Location: Australia

PostPosted: Sat Dec 17, 2011 3:32 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top