can we read records in a file from botom to top. if
possible how can we read
Answer Posted / 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 |
Post New Answer View All Answers
For rewrite, why is it mandatory that file needs to be opened?
what is difference between cobol and cobol/400
What is comp-1 and comp-2?
How to remove the spaces at the end of each record in the output file of variable length, via cobol program?
How can we find that module can be called – whether DYNAMICALLY or STATICALLY?
) How do u handle errors in BMS macro
State the various causes of s0c1, s0c5 and s0c7.
How many bytes S(8) comp field occupy and its maximum value?
What is the problem of ordered sequential files access?
What happens when we move a comp-3 field to an edited (say z (9). Zz-)?
How to get the last record in vsam file in cluster? And how can you get the ksds file records into cobol program?
Write the code implementing the perform … varying.
What is the difference between a binary search and a sequential search what are the pertinent cobol?
I have program P1 which calls file F1 which has 100 records and following structure 001 .................. 002 .................. 003 .................. 098 .................... 099 ................... 100 .................... Now I want to read these files and write these records in file F2 in following manner. 001 ...... 051 ..... 002 ...... 052 ..... 003 ...... 053 ..... .......... ....... .......... ....... .......... ....... 048 ........ 098 ...... 049 .......... 099 ....... 050 .... 100 ......
Why did you choose to work with ibm mainframe cobol programming?