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
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 |
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 |
What are INPUT PROCEDURE and OUTPUT PROCEDURE?
How to know whether the module is dynamical or statistical?
hw to create 3 dimensional array & hw to access it?
What are the pertinent COBOL commands?
Why would you use find and get rather than to obtain?
How do get the result of your program directly on your pc?
How can you pass values from COBOL program to non-COBOL programs?
If we put three reads in COBOL in the same para one after the other, to read a PS file,will it read the same record thrice or it will read three records sequentially? For example : Input File 01 02 03 Para 900 Read infile Display Infile rec Read infile Display infile rec Read infile Display infile rec. What will be the output?
How you can read the file from bottom?
how we rectify soc4 and soc7 error in project(need real time answer)? please reply
without performing any operations on a file how can i know whether it contains data or not
A s9(4). B v9(4) value 0.21 can i move this?