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

How do you define a variable of COMP-1? COMP-2?

3 Answers  


Why is it necessary that file needs to be opened in I-O mode for REWRITE?

0 Answers  


what happens if we dont close cursor in db2-cobol pgm?

6 Answers  


In which area will you utilize 88 level items in cobol?

0 Answers  


How do u sort the table for Search ALL? Is it only using ASCENDING KEY IS statement in occurs clause? If the data is input in non ascending order, will the ASC KEY IS automatically sort the data? or will it throw compile time error?

1 Answers   CTS,






study the data discriptions and answer the questions given below i)01 ORDER RECORD 05 OUT-HEADER PIC X(50) 05 ITEM-COUNT PIC 99 05 OUT-ITEM PIC X(20) OCCURS 1 TO 20 DEPENDING ON ITEM-COUNT ii)01 NAME-AND-ADDRESS 05 N-AND-A-LINE OCCURES 5 05 LINE-LENGTH PIC P9 05 N-AND-A-CHAR PIC X OCCURS 1 TO 20 DEPENDING ON LINE-LENGTH iii)01 SALES-LIST 05 SALESMAN-COUNT PIC 99 05 SALES PIC 9(6) OCCURS 1 TO 100 DEPENDING ON SALESMAN-COUNT iv)01 ORDER-RECORD 05 NO-OF-BRANDS PIC 99 05 BRAND-PURCHASED OCCURS 1 TO 15 DEPENDING ON NO-OF-BRANDS which of the following is true? a.i) and iii) are valid b.i) and iv) are valid c.i) and iii) are not valid d.all are valid

4 Answers   TCS,


What is EIBCALEN? Why it is used?

9 Answers   ADP,


How we copy a program from production region to development region.What is the process & syntax ?

3 Answers   CTS,


What is the difference between Structured COBOL Programming and Object Oriented COBOL ?

1 Answers  


If my program receives input feed from program in other system.. if the receiving field size is less than the sending field.. what abend will be happening.

1 Answers   HCL,


can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there

1 Answers  


What is an index for tables?

2 Answers  


Categories