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
 

 

Fetch every last record from a VSAM file using SORT.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
malayajena

New User


Joined: 08 Jul 2006
Posts: 28
Location: Singapore

PostPosted: Wed May 19, 2010 7:27 am    Post subject: Fetch every last record from a VSAM file using SORT.
Reply with quote

Dear All

I have a requirement where i need to fetch every last record based on some field values. The details as as below.
The data in the VSAM comes like this,..
Code:
Account No    Seq No  Distr             Country
10000000001  01        Los Angeles  USA
10000000001  02        Philadelphia  USA
10000000001  03        Newyork       USA

20000000001  01        Los Angeles  USA
20000000001  02        Philadelphia  USA
20000000001  03        Newyork       USA

30000000001  01        Los Angeles  USA
30000000001  02        Newyork      USA

and so on...
------------------------------
My Output should come as the below.
My idea of including the accounts would be based on Account No.
(like 5,6,pd,eq,10000000001,or,5,6,pd,eq,30000000001).

Code:
10000000001 03 Newyork       USA
30000000001 02 Newyork       USA
------------------------------------------Now ..coming to the data type in the columns ...
Accoun No- S9(11) Comp-3 Var
Seq No- S9(5) Comp-3 Var
And others are in Char format.
Account No+ Seq No = key of the file.

Please let me know if any more info is required and if its possible to achieve this by sort.
Back to top
View user's profile Send private message

Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 991
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed May 19, 2010 12:47 pm    Post subject:
Reply with quote

I'd suggest using ICETOOL SELECT ON(5,6,PD) LAST which will give you the last (or only) record with matching key (account number).

Adding a USING to the ICETOOL control allows you specify which accounts to INCLUDE via DFSORT control statements.

Garry.[/code]
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed May 19, 2010 9:53 pm    Post subject:
Reply with quote

malayajena,

Use the following DFSORT JCL



Code:

//STEP0100 EXEC PGM=ICETOOL                                     
//TOOLMSG  DD SYSOUT=*                                           
//DFSMSG   DD SYSOUT=*                                           
//IN       DD DSN=Your input vsam file,DISP=SHR
//OUT      DD SYSOUT=*                                           
//TOOLIN   DD *                                                 
  SELECT FROM(IN) TO(OUT) ON(5,6,PD) LAST USING(CTL1)           
//CTL1CNTL DD *                                                 
  SORT FIELDS=COPY                                               
  INCLUDE COND=(5,6,PD,EQ,10000000001,OR,5,6,PD,EQ,30000000001) 
//*
Back to top
View user's profile Send private message
malayajena

New User


Joined: 08 Jul 2006
Posts: 28
Location: Singapore

PostPosted: Thu May 20, 2010 7:23 am    Post subject: Reply to: Fetch every last record from a VSAM file using SOR
Reply with quote

Thanks a lot garry and Skolusu.
The LAST phrase solved all my concerns.
Cheers:)
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fail to change physical VSAM filename... jacobdng CICS 6 Fri Jan 20, 2017 12:36 pm
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


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