Page 1 of 1

How to skip the first records

PostPosted: Tue Feb 22, 2011 7:21 pm
by sjrcreation
Can someone tell how to skip first record of a sequence file.

get file1
**any skip comment are there to skip the first recoed** ?????
**logic**
put file2

Re: How to skip the first records

PostPosted: Wed Feb 23, 2011 12:49 am
by dick scherrer
Hello,

One easy way is to count the records read and when the count is 1, skip the record.

Another is a first-time indicator/switch.

Re: How to skip the first records

PostPosted: Wed Feb 23, 2011 6:24 am
by BillyBoyo
IF RECORD-COUNT (FILE1) EQ 1
    GO TO JOB
END-IF

Re: How to skip the first records

PostPosted: Wed Feb 23, 2011 10:38 am
by sjrcreation
Thank Deck and Billy boya.. i will try and publish the working code..

Re: How to skip the first records

PostPosted: Wed Feb 23, 2011 12:50 pm
by BillyBoyo
Thanks for the thanks.

My quick solution assumed that you have "JOB INPUT NULL", ie you are doing the reading yourself, but basically just reading the main file.

If you are reading some sort of subsidiary file, then


IF RECORD-COUNT (FILE1) NE 1
    PERFORM whatever-file-processing-you-want
END-IF



Why do you want to ignore the first record? If it is a file header, it would be better to identify it as such, and ignore it specifically because it is a file header, rather than just the first record. The file header may (should) have data on which you can check in the program that you are reading the right file (right day, right name, whatever). If there is a file header, is there a file trailer? If so, should identify it and again verify any data on it (record count, total of any fields (hash counts)).

It may seem a waste to do all this stuff, but it can save you a lot of time, and once you have your first program working, you can "clone" it for the next one, so don't have to repeat the coding of the header/trailer each time, just the checking.

Re: How to skip the first records

PostPosted: Wed Feb 23, 2011 1:02 pm
by Zio69
Old timer question: is
RECORD-COUNT (FILE1)
a new syntax?? It used to be filename:RECORD-COUNT (I'm pretty sure of that!)

Re: How to skip the first records

PostPosted: Thu Feb 24, 2011 12:30 am
by BillyBoyo
Zio69 wrote:a new syntax?? It used to be filename:RECORD-COUNT (I'm pretty sure of that!)


You're right. Sometimes I check what I think I know, the times I don't it asks for trouble.

Sorry, sjrcreation, use Zio69's code.

Re: How to skip the first records

PostPosted: Fri Feb 25, 2011 5:53 pm
by sjrcreation
Hi all, Thanks for ur repond. Zio69's code is working
so
IF file1:RECORD-COUNT NE 1
PERFORM logic1
END-IF

working :-)