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


Please Help Members By Posting Answers For Below Questions

System Testing for Mainframe Developers What is System Testing? integration testing ? what's the procedure ..

1588


What are the different data types in cobol?

790


In which area will you utilize 88 level items in cobol?

722


What is the compute verb? How is it used?

659


What is the difference between structured cobol programming and object alternativelyiented cobol?

753






What is the difference between a binary search and a sequential search? What are the pertinent cobol commands?

714


What are the rules of the move verb?

704


What are the various section in data division and briefly explain them.

698


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

776


How to get the last record in vsam file in cluster? And how can you get the kids file records into your cobol program?

740


) How do u handle errors in BMS macro?

1427


What are literals?

630


How did the release of cobol/370 version 1.3 improve the performance of release 1.1?

645


How do we get current date from system with century in COBOL?

805


here is my requirement A1 is alphanumeric with value 'A1B2C3D4' as defined below 05 A1 PIC X(8) VALUE IS 'A1B2C3D4' but i need to have A2,A3 as ABCD & 1234 repectively...... A2 = ABCD A3 = 1234 Can you please explain me what are the different ways to do it?

6825