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


Please Help Members By Posting Answers For Below Questions

How do you define a variable of comp-1 and comp-2?

705


Write a program to explain size error.

677


What is a SSRANGE and NOSSRANGE?

823


What is Pic 9v99 Indicates in COBOL?

729


How can you get the ksds file records into your cobol program?

644






1.Is it possible to move the data from 99.99 to 99v99? 2.What is the CICS-vsam Compilation process? 3.In My GDG 5 generation will be there GDG3 got an abend what will happen? 4.In my GDG first generation is +1 And I want to add the new generation what will happen previous generation? 5.How can you give the PIC clause below conditions A). s9 (reddy), B). s9 (5) occurs 5 times? 6.How override the proc from a particular step? and what is symbolic and override Procs?

5379


When is inspect verb is used in cobol?

677


Explain about different table spaces.

650


Difference between cobol and cobol-ii?

708


EXPLAIN MAIN FRAME TESTING PROCESS...HOW TO FIX THE MAINFRAME BUGS?

2060


For rewrite, why is it mandatory that file needs to be opened?

623


What is the default value(s) for an initialize? What keyword will allow for an override of the default?

661


How do you reference the following file formats from cobol programs?

695


Give some examples of command terminators?

759


What guidelines should be followed to write a structured cobol prgm?

673