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.



We are using the searching a table which is indexed, once the key is found, how can we get the occ..

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

More COBOL Interview Questions

what is the diff b/w select stsmt and cursor ?

2 Answers  


explain sorting techniques in cobol program?

0 Answers  


What is SDSF?

3 Answers  


What is sqlca and why is it needed in any cobol-db2 program?

1 Answers  


Have you code any new programs in COBOL ? What is the functionality of the programs?

2 Answers   Patni, Xansa,


Can JUSTIFIED be used for all the data types?

3 Answers  


The maximum number of dimensions that an array can have in COBOL-85 is ?

11 Answers  


COMPUTE X = A * B - C * D and COMPUTE X = (A * B) - (C * D) (a) Are not the same (b) Are same (c) Syntactically wrong (d) Will yield a run time error

1 Answers   TCS,


COBOL program to read the string ' BOMBAY' in reverse order as 'YABMOB'

8 Answers   Barclays, IBM,


What is redefines clause in COBOL?

0 Answers   B-Ways TecnoSoft,


what is soc7 abend?how u can trace it?

4 Answers   Accenture,


What is the Purpose of POINTER Phrase in STRING command

3 Answers  


Categories