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

We have 3 programms A,B,C.In the middle of the program A the controls goes to program B and in the middle of the program B control wants to go program C,after completion of program C again control comes to program B and again after completion of program B control comes to program A.How the process will takes and what are the controls we use for that process.If it is possible anybody of you explain with example?

5 Answers   IBM,


How does IDMS communicate with CICS?

1 Answers   Covansys, Satyam,


u have passed sme charecters thru parm parameter in jcl. how do u code in cobol to recieve the values u gave in parm ?

2 Answers   IBM,


How many times the loop runs here 01 a pic 9(2) value 1. perform para1 until a=10 move 1 to a. stop run. para1: move 10 to a.

5 Answers  


what is a zoned decimal data type and how it will be stored?

2 Answers   IBM,






What will happen if we move SPACES to numeric field and ZEROES to alphabetic field?

7 Answers   T systems,


suppose there is one PF having two members PF1 PF2.PF has one unique key Emp ID.could you tell me uniqueness in PF will be effective across members as well ? assume emp iD 3333 is in member PF1 would same Emp id be exist also in member PF2 ?

2 Answers   Tesco HSC, Wipro,


C1 C2 C3 are three conditions whose TRUTH values are as folloes. C1-TRUE C2-FALSE C3-TRUE A,B,C are defined as given below A:C1 AND(NOT C2) OR C3 B.(NOT C1) OR (NOT C2 AND NOT C3) C.(C1 OR C2)AND C3 D.C1 AND C2 OR C3 given the above information which of the following statements are valid? a.only A,B and C are TRUE b.only A,C and D are TRUE c.A,B,C and D are TRUE d.only C and D are TRUE

1 Answers   TCS,


What is rmode(any) ?

0 Answers  


how do you define single dimensional array and multidimensional array in your cobol?

0 Answers  


What is the output generated by the following code? 01 GRP-I. 05 SUBFLD1 PIC XX VALUE "AB". 05 FILTER PIC X(6) VALUE SPACES. 01 GRP-2 REDEFINED GRP-1. 05 SUB-FLD2 PIC XX. 05 SUB-FLD3 PIC XX. 05 FILTER PIC X(4). IF SUB-FLD1 NOT = SPACES DISPLAY "SUBFLD1" MOVE "ABBCCD" TO GRP-1 IF SUB-FLD3 = SPACES DISPLAY "SPACES" ELSE DISPLAY "SUBFLD3" DISPLAY "END" ELSE DISPLAY "SPACES" DISPLAY "END". (a) SUBFLD1 SUBFLD3 END (b) SPACES END (c) SUBFLD1 END (d) SUBFLD1 SPACES

7 Answers   TCS,


What is report-item?

1 Answers   IBM,


Categories