can we read records in a file from botom to top. if
possible how can we read

Answers were Sorted based on User's Feedback



can we read records in a file from botom to top. if possible how can we read..

Answer / ch. ranveer singh gurjar

New update..by Ch. Ranveer Singh(ACS A XEROX)
WE CAN TAKE INPUT AND OUT PUT FILE
AS

INPUT-
10
20
30

OUTPUT-
30
20
10

USE THIS PROGRAM


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).
01 EOF PIC X(1) VALUE 'N'.
01 ARRAY1.
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.
MOVE 1 TO WS-COUNT.
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-COUN

Is This Answer Correct ?    0 Yes 1 No

can we read records in a file from botom to top. if possible how can we read..

Answer / sreejith

yes it is possible by using access mode dynamic.
use START command to point last record.then start reading
using READ PREVIOUS command until first record

Is This Answer Correct ?    3 Yes 12 No

Post New Answer

More COBOL Interview Questions

What care has to be taken to force program to execute above 16 Meg line?

1 Answers  


what are the working storage fields in BMS macro?

2 Answers   IBM,


what is the difference between implicit and explicit scope terminator with example? 

1 Answers  


Which of the following characters is NOT valid in column 7? a. - b. \ c. * d. # e. $

4 Answers  


Can we put move statement in COBOL copybook

3 Answers   Global Logic,






What is the difference between subscript and index?

1 Answers  


how to convert vsam table into DB2 table?

1 Answers   IBM, Wipro,


how would find total records in files using seqientional

1 Answers   HSBC,


how to access the file from prodution from changeman tool and to submit a file to production

1 Answers   IBM,


how to change picture class of copy book variable inside program?

2 Answers  


What is XDC ?

3 Answers   Cap Gemini, IBM,


How can we find that module can be called – whether DYNAMICALLY or STATICALLY?

0 Answers  


Categories