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 / preethi

Declare table , and a index variable in the working storage section.

Procedure Division.

Open file1.
perform para1 thru para1-exit until end-of-file.
perform display-para thru display-para-exit.
close file1.
go back.
Para1.
read file1 into ws-file1
at end
end-of-file
set index-diff to index
not at end
move ws-file1-num to table-num(index)
set index up by 1
end-read.
para1-exit.
exit.

Display-para.
subtract 1 from index-diff.
perform until index-diff = 0
display table-num(index-diff)
set index-diff down by 1
end-perform.

display-para-exit.
exit.

Is This Answer Correct ?    5 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Mention the guidelines to write a structured cobol program?

620


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 ......

10626


Write a cobol program making use of the redefine clause.

736


What is amode(24), amode(31), rmode(24) and rmode(any) (applicable to only mvsesa enterprise server) ?

676


) How do u handle errors in BMS macro

1512






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

2060


what is the difference between COBOL2 AND COBOL390?

2453


Write a program that uses move corresponding.

673


Write the code implementing the perform … varying.

646


What is the utilization of copybook in cobol?

657


Write some characteristics of cobol as means of business language.

619


can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there

1908


Which mode is used to operate the sequential file?

669


how do you reference the rrds file formats from cobol programs

801


What rules are followed by the search verb.

638