i have a file which contains records like
10,30,90,50,20,40,80,60,70
i want to display these records in reverse order like
70,60,80,40,20,50,90,30,10
please give me the cobol code (do not sort the records)
Answer Posted / ch.ranveer singh gurjar
ou can try this i will give 100% exact output...by
CH. RANVEER SINGH GURJAR
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) VALUE ZEROS.
01 EOF PIC X(1) VALUE 'N'.
01ARRAY1.
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.
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-COUNT.
| Is This Answer Correct ? | 2 Yes | 7 No |
Post New Answer View All Answers
What type of SDLC u followed? Why?
What are declaratives and what are their uses in cobol?
How many bytes S(8) comp field occupy and its maximum value?
How you can read the file from bottom?
) How do u handle errors in BMS macro
how to move the records from file to array table. give with code example
What guidelines should be followed to write a structured cobol prgm?
What is the difference between binary search and sequential search?
What is an in line perform? When would you use it? Anything else you wish to say about it.
What is the default value(s) for an initialize and what keyword allows for an override of the default?
how to access the file from prodution from changeman tool and to submit a file to production
What are the different rules of SORT operation?
how do you reference the fixed unblock file formats from cobol programs
What is rmode(any) ?
What is the default value(s) for an initialize? What keyword will allow for an override of the default?