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

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

661


How to fetch 1000 error records from VSAM file(Eg: 1000000 records present) while getting SOC7 abend ?

1921


how can i see junk values in dclgen or in hostvariable of comp ?

2536


which is Best IBM Mainframe Training and Placement Institute in Ameerpet Hyderabad

1017


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

765






What are the access modes of START statement?

713


i need a small 3d program using inline and outline.

1629


Explain how will you differentiate between an internal and an external sort, the pros and cons, internal sort syntax etc

812


example for sub strings ? and refernce modifications whit output pls

1838


How to remove the spaces at the end of each record in the output file of variable length, via cobol program?

667


How do you code cobol to access a parameter that has been defined in jcl? And do you code the parm parameter on the exec line in jcl?

690


State the various causes of s0c1, s0c5 and s0c7.

656


What is the difference between external and global variables in COBOL?

806


A table has two indexes defined. Which one will be used by the SEARCH?

750


What do you understand by psb and acb?

659