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

How to read last record in VSAM file in batch processing?


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

New User


Joined: 13 May 2005
Posts: 38

PostPosted: Fri Sep 01, 2006 12:05 am
Reply with quote

Hi,

Please let me know How to read last record in VSAM file in batch processing?

Regards,
Umed
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Fri Sep 01, 2006 1:10 am
Reply with quote

Sort it backwards and REPRO to SYSOUT with COUNT(1).

O.
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: Fri Sep 01, 2006 2:23 am
Reply with quote

Quote:
Sort it backwards and REPRO to SYSOUT with COUNT(1).


You don't need two passes (SORT and REPRO). You can do it all in one pass with a DFSORT job like this:

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VSAM)
//SORTOUT DD DSN=... output file (VSAM or VB)
//SYSIN DD *
* Add sequence numbers. Use them to reverse the order of
* the records.
  RECORD TYPE=V
  INREC FIELDS=(1,4,5:SEQNUM,8,ZD,13:5)
  SORT FIELDS=(5,8,ZD,D)
* Get the last record.  Remove the sequence number.
  OUTFIL ENDREC=1,OUTREC=(1,4,13)
/*
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 18, 2008 2:26 am
Reply with quote

You can now do this more 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 (VSAM)                                     
//OUT DD DSN=...  output file (VSAM or VB)       
//TOOLIN DD *                                                     
SUBSET FROM(IN) TO(OUT) KEEP INPUT TRAILER VSAMTYPE(V)
/*     


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

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top