How to read records in reverse order in flat file?
I know we can do it by reading all records into an array....
Then read records in reverse order by using subscript or index
but can any body give me the exact code.
Answer Posted / ch. ranveer gurjar
you can try this i will give 100% exact output...by
CH. RANVEER SINGH GURJAR
IDENTIFICATION DIVISION.
PROGRAM-ID. 'OCCURS'.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INFILE ASSIGN TO DD1.
SELECT OUTFILE ASSIGN TO DD2.
DATA DIVISION.
FILE SECTION.
FD INFILE.
01 INREC.
05 IN-EMP-ID PIC X(5).
05 IN-EMP-NAME PIC X(10).
05 FILLER PIC X(65).
FD OUTFILE.
01
OUTREC.
05 OUT-EMP-ID PIC X(5).
05 OUT-EMP-NAME PIC X(10).
05 FILLER PIC X(65).
WORKING-STORAGE
SECTION.
01 WS-COUNT PIC 9(4) VALUE ZEROS.
01 EOF PIC X(1) VALUE 'N'.
01ARRAY1.
05 ARREC OCCURS 1 TO 50 TIMES DEPENDING ON WS-COUNT.
10 AR-EMP-ID PIC X(5).
10 AR-EMP-NAME PIC X(10).
PROCEDURE
DIVISION.
OPEN INPUT
INFILE.
OPEN OUTPUT
OUTFILE.
PERFORM MOVE-RECORD UNTIL EOF = 'Y'.
PERFORM PARA1 UNTIL WS-COUNT = ZEROS
CLOSE
INFILE.
CLOSE OUTFILE.
STOP RUN.
MOVE-RECORD.
READ INFILE AT END MOVE 'Y' TO EOF
NOT AT END
MOVE INREC TO ARREC(WS-COUNT)
ADD 1 TO WS-COUNT.
PARA1.
MOVE ARREC(WS-COUNT) TO OUTREC
WRITE OUTREC
SUBTRACT 1 FROM WS-COUNT.
| Is This Answer Correct ? | 12 Yes | 3 No |
Post New Answer View All Answers
what is search and searchall?what is the diffrence between them?give an best example?
Explain how will you differentiate between an internal and an external sort, the pros and cons, internal sort syntax etc
What kind of error is trapped by on size error option?
What is link edit in cobol?
How do you reference the fixed block file formats from cobol programs
State the various causes of s0c1, s0c5 and s0c7.
If you are current on the owner of a set, what is the difference between obtain next and obtain first?
What do you understand by psb and acb?
how do you reference the esds vsam file formats from cobol programs
i want to learn mainframe..any websites and material to learn from basic..? my mail id : rajeswaribe2010@gmail.com
Define cobol?
What is the Purpose of POINTER Phrase in STRING command in COBOL?
how do you reference the printer file formats from cobol programs
Which mode is used to operate the sequential file?
How to get the last record in vsam file in cluster? And how can you get the ksds file records into cobol program?