skip the first and last record of a file



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

skip the first and last record of a file

Postby Kal El » Wed Jul 28, 2010 3:07 pm

I have an input file with 1st and last record containing a date field.I want to skip these records.Kindly let me know how to do so.

These records contain date values.
Kal El
 
Posts: 9
Joined: Mon Jun 21, 2010 1:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: skip the first and last record of a file

Postby NicC » Wed Jul 28, 2010 7:48 pm

Question is...what have you tried so far? I would try reading the first 2 records, save the second record, read the next record, if not end of file then process saved record, save third record, read next record, if not end of file.....when end of file do not process last record read.

Or run through some utility e.g a sort and drop firat and last records that way and then process the resultant file. Which way you go is up to you/your shop standards etc.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: skip the first and last record of a file

Postby dick scherrer » Thu Jul 29, 2010 1:09 am

Hello,

If the file has 400,000,000 records, i'd suggest doing it with the code rather than a separate utility step to copy the file minus the 2 unwanted records. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: skip the first and last record of a file

Postby Kal El » Sun Aug 08, 2010 5:08 pm

At first I thought of using an inspect clause on the first record...as it has a different value(date) than the rest of the data in the file...so the moment i encounter date i shall skip it go to the next record..and resume processing....However if the second record also happens to be a date due to some error etc. then my code will skip it as well.....
Kal El
 
Posts: 9
Joined: Mon Jun 21, 2010 1:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: skip the first and last record of a file

Postby NicC » Sun Aug 08, 2010 8:15 pm

Why look at the first record at all? Ypu know it is ithe first record because it is your first read and your count of records read should be 1. Obviously you cannot do the same wih the last record but if it is a trailer record then it would have identifier that you could look for and when you get it just ignore the record, set end-of-file manually and continue to end of program.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: skip the first and last record of a file

Postby Vikrant Survase » Thu Aug 12, 2010 1:47 pm

yaa just read 2 records at a time and use count ,frist time skip the frist record and for last time skip the second record.
hope this will help.
Vikrant Survase
 
Posts: 19
Joined: Fri Jun 04, 2010 9:08 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post