We are using the searching a table which is indexed, once
the key is found, how can we get the occurance at which the
key was found.
Answer Posted / shobhit
Initialize the index and a variable to 1 before search.
SET IDX VAR-POS TO 1.
SEARCH TABLE VARYING VAR-POS
AT END DISPLAY "Not Found"
WHEN TABLE(IDX) = <SEARCH STRING>
MOVE VAR-POS TO RESULT-VAR
DISPLAY "FOUND AT POSITION" RESULT-VAR
END-SEARCH.
Now the position is available in the variable RESULT-VAR.
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
How to get the last record in vsam file in cluster? And how can you get the kids file records into your cobol program?
Which is not true about evaluate statement
What are declaratives and what are their uses in cobol?
How to print 10 to 1 if the input have only 10 digit number?
What is redefines clause in COBOL?
How to get the last record in vsam file in cluster? And how can you get the ksds file records into your cobol program?
How do u write test cases?
Which mode is used to operate the sequential file?
How do we get current date from system with century in COBOL?
How can i load all the data from a file to Table (array) in cobol.How i manage the occurs clause with out reading the file.Any options avilable ? Please can any one help me it is urgent?
What is the difference between perform … with test after and perform … with test before?
How did the release of cobol/370 version 1.3 improve the performance of release 1.1?
Is it possible that the redefines clause has different picture clauses compared to the one it redefined?
Difference between cobol and cobol-ii?
What is the difference between goback, stop run and exit program in cobol?