Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 998
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 Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts VSAM RLS Wait time blayek JCL & VSAM 2 Mon Oct 02, 2017 9:05 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us