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
Differentiate between structured cobol programming and object-oriented cobol programming.
How to fetch 1000 error records from VSAM file(Eg: 1000000 records present) while getting SOC7 abend ?
how can i see junk values in dclgen or in hostvariable of comp ?
which is Best IBM Mainframe Training and Placement Institute in Ameerpet Hyderabad
What happens when we move a comp-3 field to an edited (say z (9). Zz-)?
What are the access modes of START statement?
i need a small 3d program using inline and outline.
Explain how will you differentiate between an internal and an external sort, the pros and cons, internal sort syntax etc
example for sub strings ? and refernce modifications whit output pls
How to remove the spaces at the end of each record in the output file of variable length, via cobol program?
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?
State the various causes of s0c1, s0c5 and s0c7.
What is the difference between external and global variables in COBOL?
A table has two indexes defined. Which one will be used by the SEARCH?
What do you understand by psb and acb?