Thread: COBOL

SEARCH ALL returns not found but the key is in the table

Started by Tyler • user4 replies233 viewsLast activity 1 week ago
Post #1
0 votes
Tyler
Reputation
34
Posts: 19
Joined: Nov 8, 2025, 1:44 PM
Posted: Aug 2, 2026, 10:45 AM

OCCURS 400 ASCENDING KEY IS TAB-KEY INDEXED BY IND-TAB. Only first ~80 slots filled. SEARCH ALL says not found for a key I can see in slot 12.

Do I need OCCURS DEPENDING ON?

Post #2
1 votes
Marty
Reputation
412
Posts: 58
Joined: Aug 12, 2024, 9:14 AM
Posted: Aug 2, 2026, 12:45 PM

SEARCH ALL binary-searches the whole 400. Empty slots are low-values or spaces, so the "sorted" order is broken and the search walks into garbage.

OCCURS DEPENDING ON ws-count (set to 80) is the clean fix. Or pad unused keys with HIGH-VALUE so they sort after real data. ODO is better.

Post #3
0 votes
Anita
Reputation
118
Posts: 23
Joined: May 29, 2025, 12:45 PM
Posted: Aug 2, 2026, 4:45 PM

And the table has to actually be in key sequence. SEARCH ALL will not sort it for you.

Post #4
0 votes
Tyler
Reputation
34
Posts: 19
Joined: Nov 8, 2025, 1:44 PM
Posted: Aug 3, 2026, 12:45 PM

ODO + SORT of the table before SEARCH ALL. Works.

You must be signed in to reply to this thread