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

Explain what you understand by passing by value.

0 Answers  


How to convert bunch of words in a line to relvant ASCII values?

2 Answers  


please..could u give an example about USAGE IS POINTER ..and explain why and when we use it ?

0 Answers   EDS,


i have mainprogram and subgram...if i compile mainprogram without stop run..what will u get in compilation time?

1 Answers   HCL,


What is the difference between Global and External Variables?

0 Answers  






What is the difference between comp and comp-3 usage? Explain other COBOL usage?s.

3 Answers   IBM, Xansa,


how to access the file from prodution from changeman tool and to submit a file to production

1 Answers   IBM,


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

0 Answers   Valtech,


what is the difference between external and global variables?

1 Answers  


How do you reference the following file formats from cobol programs?

0 Answers  


Hi All, how is sign is stored in S9(17) comp-3 variable. Answer with an Example will be of great help.

5 Answers   EDS,


Give some examples of command terminators?

0 Answers  


Categories