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

How To Separate The Numerics From An Alphanumric Data Item Which Contains Both Alphabates And Numerics ?

4 Answers  


What is Comm?

2 Answers   IBM, Kemper Corporation,


In COBOL, what is the different between index and subscript?

0 Answers   TryTechnicals Pvt Ltd,


COMP-3 field occupy ?

8 Answers  


How do you define a variable of comp-1 and comp-2?

0 Answers  


Suppose i have a variable with s9(18)v99 comp3 . what is the size of variable . If s9(18) comp3 is 10 bytes . There should be some difference between two allocations ? Thanks krishna chaitanya

2 Answers   CSC,


example for sub strings ? and refernce modifications whit output pls

0 Answers   College School Exams Tests, IBM,


can we print comp 3 stmts how ?

3 Answers   Accenture, TCS,


Can we dynamically increase the size of occurs clause? i.e In case I an not sure of the size of array and want to increase the size at run time.If yes , how?

1 Answers  


give the examples of strings in cobol

1 Answers   IBM,


how to pass 100 to s9(4) how r they inserted ?

3 Answers   TCS,


what is the difference between PA & PF keys?

1 Answers   IBM,


Categories