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

input= ,,,, mainframe training ,,, hyderabad .... location.... output1=$ mainframe training in hyderabad location$ output2=**** mainframe training in hyderabad location ****. In this pgn when we give input considering the spaces the output is displayed in this format.Like in the place of ,,,, $ should be displayed likewise.So please helpmeout.

1776


Is it possible that the redefines clause has different picture clauses compared to the one it redefined?

670


Hi pls anybody tell me about " ANALYSIS DOCUMENT PREPARATION AND ESTIMATION OF TASK " (in real time project)."I want to update a sequential file in my project" for that purpose i need both structures i mean analysis document and estimation of task.

1697


What are the different open modes available in cobol?

713


i was faced one question- i have value -00001234.56 Suppress the zeroes and the output should be -1234.56 But Not - 1234.56 spaces should not be available after suppressing the zeroes. logic in jcl and cobol?

892






What are the pertinent COBOL commands?

2620


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

637


how do you reference the variable unblock file formats from cobol programs

743


Can we redefine the field of x(200) to less than 200?

814


What are INPUT PROCEDURE and OUTPUT PROCEDURE?

679


What is cobol?

741


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

709


how we sort two input files based on a common column and giving one o/p file please send me the coding logic?

1646


What is the utilization of copybook in cobol? Could we utilize a similar copybook?

711


What is the utilization of copybook in cobol?

650