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?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different rules of SORT operation?

904


Explain how to differentiate call by context by comparing it to other calls?

910


Name the sections present in data division.

911


What are 77 levels used for?

848


What are INPUT PROCEDURE and OUTPUT PROCEDURE?

949


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

2185


What is rmode(any) ?

899


What is rmode(24)

903


What are the different open modes available in cobol?

945


I need to compare 3 variables(dates) and do some processing based on the earliest date. There could be more then 1 date record in any of the 3 fields. What is the best way to code this?

2015


What is the difference between next sentence and continue in cobol programing language?

956


What is amode(24)?

886


Write a program to enter and display the names of students in a class using the occurs clause.

933


What is the problem of ordered sequential files access?

912


What is the default value(s) for an initialize and what keyword allows for an override of the default?

959