i have a file which contains records like
i want to display these records in reverse order like
please give me the cobol code (do not sort the records)
Declare table , and a index variable in the working storage section.
perform para1 thru para1-exit until end-of-file.
perform display-para thru display-para-exit.
read file1 into ws-file1
set index-diff to index
not at end
move ws-file1-num to table-num(index)
set index up by 1
subtract 1 from index-diff.
perform until index-diff = 0
set index-diff down by 1
01 WS-COUNT PIC 9(4) VALUE ZEROS.
01 EOF PIC X(1) VALUE 'N'.
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).
PERFORM MOVE-RECORD UNTIL EOF = 'Y'.
PERFORM PARA1 UNTIL WS-COUNT = ZEROS
READ INFILE AT END MOVE 'Y' TO EOF
NOT AT END
MOVE INREC TO ARREC(WS-COUNT)
ADD 1 TO WS-COUNT.
MOVE ARREC(WS-COUNT) TO OUTREC
SUBTRACT 1 FROM WS-COUNT.
Is This Answer Correct ?
Ch.ranveer Singh Gurjar
Other COBOL Interview Questions
What are the differences bitween cobol and cobol-2?
I have a PS file and I would like to manually insert the
binary values (like a COMP format) into the file. How can i
do that? the way do in COMP-3 format.. suppose i want to
insert -12345 in to file in comp-3 format. simply we can
open a file in edit mode and do HEX-ON and insert the
in 3 bytes - this will be COMP-3 presenatation of -12345.
given the following piece of code:
CALL SUB-PGM USING A, B, C.
CALL SUB-PGM USING A, C, C.
(a) Both CALL statements will always produce same result.
(d) Both CALL statements may produce different result.
(c) Compile-time error because SUB-PGM is a dataname.
(d) Compile-time error because A, B, C are used twice.