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
Mention the guidelines to write a structured cobol program?
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 ......
Write a cobol program making use of the redefine clause.
What is amode(24), amode(31), rmode(24) and rmode(any) (applicable to only mvsesa enterprise server) ?
) How do u handle errors in BMS macro
EXPLAIN MAIN FRAME TESTING PROCESS...HOW TO FIX THE MAINFRAME BUGS?
what is the difference between COBOL2 AND COBOL390?
Write a program that uses move corresponding.
Write the code implementing the perform … varying.
What is the utilization of copybook in cobol?
Write some characteristics of cobol as means of business language.
can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there
Which mode is used to operate the sequential file?
how do you reference the rrds file formats from cobol programs
What rules are followed by the search verb.