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
 

 

How can read the last record of a sequential file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
ashokkumarsahu

New User


Joined: 03 Aug 2005
Posts: 6
Location: bangalore

PostPosted: Wed Aug 10, 2005 3:19 pm    Post subject: How can read the last record of a sequential file
Reply with quote

How can we read the last record of a sequential file?
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Wed Aug 10, 2005 4:13 pm    Post subject: Re: How can read the last record of a sequential file
Reply with quote

Hi ashok,

Quote:
How can we read the last record of a sequential file?

Answer is a simple READ stmt....Use AT END there to identify its a last record....Like....

Code:
READ INPUT-FILE INTO INPUT-REC               
            AT END SET END-INFILE-YES TO TRUE
                    GO TO PARA-EXIT         
END-READ.     

IF END-INFILE-YES
...
...
END-IF.     


IF statement will be executed at lastr record only....you can give your executable statements there, as per your need....

Regards,

Priyesh.
Back to top
View user's profile Send private message
shivashunmugam Muthu

Active User


Joined: 22 Jul 2005
Posts: 114
Location: Chennai

PostPosted: Wed Aug 10, 2005 4:28 pm    Post subject: Re: How can read the last record of a sequential file
Reply with quote

Hi Priyesh,

If the file isvery huge, we shall sort it as per the discussion we had earlier & then proceed from first.

I think it will give superior performance rather than reading the file till end.

Correct me if am wrong....

Shiva
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Wed Aug 10, 2005 4:50 pm    Post subject: Re: How can read the last record of a sequential file
Reply with quote

Hi Shiva,

You are correct in terms of Performance.... There can be more solutions considering more IFs & BUTs ....Adding SEQNUM to the records will be very effactive.... That is more optimized than a simple read till LAST considering performance issue.

Regards,

Priyesh.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Aug 10, 2005 8:52 pm    Post subject:
Reply with quote

Actually, we can use a DFSORT copy which will be more efficient than a sort. For this example, I'll assume that the input file has RECFM and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN  DD *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,TRAILER1=(1,80)
/*
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Aug 12, 2005 5:25 am    Post subject:
Reply with quote

Hi Ashok,

If you have FileAid you can try this. It's probably one of the more efficient ways to get what you want because it probably uses Assembler to go directly to the last rec.
Code:
//COPYREC EXEC PGM=FILEAID
//DD01     DD  DSN=YOUR.FILE,etc...
//DD01O    DD  DSN=file.contains.last.rec,etc...
//SYSIN    DD  *
$$DD01 COPYBACK OUT=1
/*
[/code]
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Oct 01, 2008 3:13 am    Post subject:
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:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 5 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm


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