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
What are the different rules of SORT operation?
Explain how to differentiate call by context by comparing it to other calls?
Name the sections present in data division.
What are 77 levels used for?
What are INPUT PROCEDURE and OUTPUT PROCEDURE?
please..could u give an example about USAGE IS POINTER ..and explain why and when we use it ?
What is rmode(any) ?
What is rmode(24)
What are the different open modes available in cobol?
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?
What is the difference between next sentence and continue in cobol programing language?
What is amode(24)?
Write a program to enter and display the names of students in a class using the occurs clause.
What is the problem of ordered sequential files access?
What is the default value(s) for an initialize and what keyword allows for an override of the default?