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

Fetch every last record from a VSAM file using SORT.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed May 19, 2010 12:47 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
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
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top