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
Define static linking and dynamic linking.
What is the local-storage section?
here is my requirement A1 is alphanumeric with value 'A1B2C3D4' as defined below 05 A1 PIC X(8) VALUE IS 'A1B2C3D4' but i need to have A2,A3 as ABCD & 1234 repectively...... A2 = ABCD A3 = 1234 Can you please explain me what are the different ways to do it?
How to read the 2nd last record of a VSAM file? (The file size is huge and we don't know the key)
) How do u handle errors in BMS macro?
Explain the configuration section of a cobol program with examples of syntax.
What is the LINKAGE SECTION used in COBOL?
What is an in line perform? When would you use it? Anything else you wish to say about it.
Write the code to count the sum of n natural numbers.
example for sub strings ? and refernce modifications whit output pls
Write some characteristics of cobol as means of business language.
How do define dynamic array in cobol.
What is amode(31)
HOw can I get the negative sign while deduct high value from low value
How do you get the data to code the BMS macro?