How do u sort the table for Search ALL? Is it only using
ASCENDING KEY IS statement in occurs clause? If the data is
input in non ascending order, will the ASC KEY IS
automatically sort the data? or will it throw compile time
error?



How do u sort the table for Search ALL? Is it only using ASCENDING KEY IS statement in occurs claus..

Answer / snehatechm

for using SEARCH ALL your table must be defined with KEY IS
along with the OCCURS caluse and INDEXED BY.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 XXX-TABLE.
03 XXX-TEXT PIC X OCCURS 10 TIMES
ASCENDING KEY IS XXX-TEXT
INDEXED BY AXIDX.

In the above case my table is ordered in ascending sequence.
i can order my table in descending sequence also.

01 SRCHXXX PIC X.
01 XXXPOS PIC 99.

PROCEDURE DIVISION.
Begin.
ACCEPT SRCHXXX
SET AXIDX TO 1
SEARCH ALL XXX-TEXT
AT END DISPLAY "NO LETTER FOUND"
WHEN XXX-TEXT(AXIDX) = SRCHXXX
SET XXXPOS TO AXIDX
DISPLAY SRCHXX " IS IN " XXXPOS
END-SEARCH
STOP RUN.

If data input in non ascending order, the ASC KEY will not
automatically sort the data

Is This Answer Correct ?    10 Yes 0 No

Post New Answer

More COBOL Interview Questions

COMP-3 field occupy ?

8 Answers  


What is the difference beetween Arrays and Tables in Cobol? please dont give the answer that arrays in cobol terminology is called tables......

3 Answers   BirlaSoft,


input 1 input2 ouput1 output2 output 3 1 re 300 1 re 200 1 re 300 3 rc 500 1 re 200 2 rr 400 1 re 300 2 rr 400 1 rc 400 3 rc 500 1 rc 400 2 rr 700 2 rr 700 5 tt 900 5 tt 900 2 inputs r in flat file and output 1 is matched records,ouptput2 is unmatched of input1,output3 is unmatched of input2! how vl u get the output files using sequential order and to check with each and every records! let me know the procedure division ?

0 Answers  


What is the maximum size of a 01 level item in COBOL I? in COBOL II?

2 Answers   IBM, RBS,


Why IBM?

1 Answers   IBM,






i have n records in one file and in this file there is some fields and i want to count that how many sharma in my file so plz give the coding that how we read sharma ?

2 Answers  


comp-3 field occupy?

5 Answers  


01 a pic s9(5) occupies how many bytes ?

9 Answers   Wipro,


Hi................... I have records like this aaaa cccc bbbb And i want output like this bbbb cccc aaaa How can it possible ?. Note:Please make sure records are in unsorted order. somebody plzzz help me.

1 Answers  


what is srange and nosrange pls reply to ths question ?

2 Answers   L&T,


What is Pic 9v99 Indicates in COBOL?

0 Answers   SwanSoft Technologies,


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

0 Answers  


Categories