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
What is perform what is varying?
how can we apply for HSBC exam(Mainframe) in India??? i went to their site and was told to submit my CV ,. etc..( totally confusing...)
what is difference between cobol and cobol/400
What is the difference between comp and comp-3?
if we display var1 then what will b displayed in below condition. 77 var1 pic s9(2) value -10. 77 var1 pic s9(2) value -11. " " " -12. " " " -13. -14 ... ... -19.
In which area will you utilize 88 level items in cobol?
What are the different rules to perform a Search?
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?
A table has two indexes defined. Which one will be used by the SEARCH?
Difference between cobol and cobol-ii?
i want a program using by if, evaluate , string, unstring, perform, occurs?
HOw can I get the negative sign while deduct high value from low value
In COBOL, what is the different between index and subscript?
how to refer the data field?
What is amode(24)?