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

Reding the last but previous line of a PS file


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ravindran1185

New User


Joined: 03 Nov 2008
Posts: 7
Location: Chennai

PostPosted: Tue Jun 16, 2009 1:12 pm
Reply with quote

Hi,

The scenario is to read the last but previous line of a PS file all the times.
i have explained two logics 1) the Count-1 logic, But the file may contain millions of record. 2) reading the PS file backwards, but No key will be specified for that file.

If anybody knows the optimized logic, please post here.

Thanks in advance.
Back to top
View user's profile Send private message
salltm

New User


Joined: 21 Aug 2008
Posts: 8
Location: china

PostPosted: Tue Jun 16, 2009 1:16 pm
Reply with quote

it is difficult .. i suggest you create a index of the file..use the key way to read the file...
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Jun 16, 2009 2:00 pm
Reply with quote

Code:

//STEP0100 EXEC PGM=ICETOOL             
//SYSOUT   DD SYSOUT=*                 
//TOOLMSG   DD SYSOUT=*                 
//DFSMSG    DD SYSOUT=*                 
//IN   DD  dsn=your input file
//OUT  DD  dsn=your output file           
//TOOLIN    DD *                                       
  SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST(2)           
/*                                     


Now I will read first record of output file (which is actually second last record of input file)
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Jun 16, 2009 2:04 pm
Reply with quote

salltm wrote:
it is difficult .. i suggest you create a index of the file..use the key way to read the file...

How would you create an index for a PS file ?
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Jun 16, 2009 3:25 pm
Reply with quote

ravindran1185 wrote:
2) reading the PS file backwards...


I hope you know that's not possible.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Jun 16, 2009 3:57 pm
Reply with quote

Hi.

I know fileaid allows you to read the file backwards.


Gerry
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jun 17, 2009 7:20 am
Reply with quote

Hello,

Why are the last 2 records needed?

If the file is huge (hundreds of millions of records or whatever) suggest that when the file is created, the process could create another little file that contains only the last 2 records. . . Or these 2 entries might be put in some database table . . . Or. . .
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
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