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

What are the different rules for performing sort operation?

851


Differentiate cobol and cobol-ii. (Most of our programs are written in cobolii, so, it is good to know, how, this is different from cobol)?

729


How do we get current date from system with century in COBOL?

928


Differentiate between structured cobol programming and object-oriented cobol programming.

751


What rules are followed by the search verb.

719






What is amode(31)

807


What happens when we move a comp-3 field to an edited (say z (9). Zz-)?

897


Explain how to differentiate call by context by comparing it to other calls?

792


please..could u give an example about USAGE IS POINTER ..and explain why and when we use it ?

2061


What is perform what is varying?

805


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

727


how to convert the recors form vsam file to db2 table tru file aid

2853


how to move the records from file to array table. give with code example

2315


What are the cobol coding sheets?

745


) How do u handle errors in BMS macro

1588