How to read the last 100 records from a COBOL file. The file
contains N number of records.
Answer Posted / bibhuti swain
PROCEDURE DIVISION.
PARA.
OPEN INPUT STUDFILE.
PERFORM PARA1 UNTIL EOF = 1.
DISPLAY 'TOTAL NO:OF RECORDS ' A.
COMPUTE B = A - 100.
MOVE 0 TO EOF.
CLOSE STUDFILE.
OPEN INPUT STUDFILE.
PERFORM PARA2 UNTIL EOF = 1.
CLOSE STUDFILE.
STOP RUN.
PARA1.
READ STUDFILE AT END MOVE 1 TO EOF.
COMPUTE A = A + 1.
PARA2.
READ STUDFILE AT END MOVE 1 TO EOF.
COMPUTE C = C + 1.
IF C >= B AND EOF NOT = 1
DISPLAY STUD-REC.
If anybody doesn't understand this logic i can explain..
In PARA2 the file is read from the beginning and the moment
the value of C reaches the value of B i.e value of C = B
and then it will satisfy the condition IF C >= B and from
there it will start displaying the records till end.
| Is This Answer Correct ? | 14 Yes | 1 No |
Post New Answer View All Answers
What is rmode(any) ?
How did the release of cobol/370 version 1.3 improve the performance of release 1.1?
how to refer the data field?
What is redefines clause in COBOL?
How do get the result of your program directly on your pc?
HOw can I get the negative sign while deduct high value from low value
What is an in line perform? When would you use it? Anything else you wish to say about it.
What is the difference between binary search and sequential search?
how to access the file from prodution from changeman tool and to submit a file to production
what are decleratives in cobol?
How do we get current date from system with century in COBOL?
What do you understand by psb and acb?
what is s000 u4087 error? please give the all error codes in cobol,jcl.
i want a program using by if, evaluate , string, unstring, perform, occurs?
There are 5 fields and 1000 records in a file. Unload it into an array. Write the syntax for declaration and how will you unload it.