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

to get last Rec


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prabhu2006

New User


Joined: 09 Jan 2006
Posts: 5

PostPosted: Mon Jan 09, 2006 5:36 pm
Reply with quote

Hi,
How do you get the last record in a file by using Sort/Icetool whose total count of recs is unknown?

Thanks & Regards
Prabhu
Back to top
View user's profile Send private message
rajesh_1183

Active User


Joined: 24 Nov 2005
Posts: 121
Location: Tadepalligudem

PostPosted: Mon Jan 09, 2006 6:05 pm
Reply with quote

Hi prabhu,

Try this ....

assuming the key is like a number
1
8
3
6
5
4
2
10
9....

if u sort in descending order...........the records will be in this order
1
2
3
4
5
6
7
8
9
10

if u sort in descending order...........the records will be in this order
10
9
8
7
6
5
4
3
2
1

where the last record is at top...so to retrive that record use "STOPAFT=1"

which will retrieve the record with key 10 which is a last record after sorting..........

corrections welcomed........

Thanks,
Rajesh
Back to top
View user's profile Send private message
rajesh_1183

Active User


Joined: 24 Nov 2005
Posts: 121
Location: Tadepalligudem

PostPosted: Mon Jan 09, 2006 6:07 pm
Reply with quote

sorry the first sort is as per in ascending order
Back to top
View user's profile Send private message
rajesh_1183

Active User


Joined: 24 Nov 2005
Posts: 121
Location: Tadepalligudem

PostPosted: Mon Jan 09, 2006 6:27 pm
Reply with quote

or simply sort using descending order and fetch the first record by "STOPAFT=1" which will be the last record(when sorted in ascending order)

Thanks,
Rajesh
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Jan 09, 2006 9:19 pm
Reply with quote

See the "Keep the last n records" Smart DFSORT Trick at:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
prabhu2006

New User


Joined: 09 Jan 2006
Posts: 5

PostPosted: Wed Jan 11, 2006 11:07 am
Reply with quote

Thaz cool...got it friends
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Sep 25, 2008 2:08 am
Reply with quote

You can now do this kind of thing quite easily using the new SUBSET operator of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:


Code:
 
//S1  EXEC  PGM=ICETOOL                                           
//TOOLMSG   DD  SYSOUT=*                                           
//DFSMSG    DD  SYSOUT=*                                           
//IN DD DSN=...  input file                                       
//OUT DD DSN=...  output file         
//TOOLIN DD *                                                     
SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST
/*     


For complete details on the new SUBSET function and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links
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

 


Search our Forums:

Back to Top