Highlighted
Absent Member.
Absent Member.
1057 views

SEARCH ALL not working in COBOL -Microfocus on UNIX Platform

Jump to solution

Code looks like below.

       01  T1-DS-FDBK-TBL.
           05  T1-DS-FDBK-ENTRY  OCCURS  999 TIMES
                                     ASCENDING KEY IS T1-DS-FDBK-UNIT
                                     INDEXED BY T1-NDX.
               10  T1-DS-FDBK-UNIT         PIC X(4).
               10  T1-DS-FDBK-RPTIND       PIC X(1).

.

.

    SEARCH ALL T1-DS-FDBK-ENTRY
        AT END MOVE 'Y'                TO WS-FDBK-TO-RPT-SW
         WHEN T1-DS-FDBK-UNIT(T1-NDX) = WS-DIV-SUB
              MOVE T1-DS-FDBK-RPTIND(T1-NDX) TO WS-FDBK-TO-RPT-SW
    END-SEARCH.

I actually don't find any reason, why binary search would not be successful.

Tags (2)
0 Likes
2 Solutions

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: SEARCH ALL not working in COBOL -Microfocus on UNIX Platform

Jump to solution
SEARCH ALL executes a binary search. It will only work as expected on an ordered table.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: SEARCH ALL not working in COBOL -Microfocus on UNIX Platform

Jump to solution
Figured this. Data loaded in the table was ordered. However key initialized to default low-values, thus entire table is not ordered. Try to initialize key to high-values

View solution in original post

0 Likes
3 Replies
Highlighted
Respected Contributor.
Respected Contributor.

RE: SEARCH ALL not working in COBOL -Microfocus on UNIX Platform

Jump to solution
I had a similar issue, not in Micro Focus Cobol, but with IBM Enterprise Cobol. The SEARCH ALL would fail to find entries that I knew were in the table. When I changed my code to an ordinary SEARCH, it worked fine.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: SEARCH ALL not working in COBOL -Microfocus on UNIX Platform

Jump to solution
SEARCH ALL executes a binary search. It will only work as expected on an ordered table.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: SEARCH ALL not working in COBOL -Microfocus on UNIX Platform

Jump to solution
Figured this. Data loaded in the table was ordered. However key initialized to default low-values, thus entire table is not ordered. Try to initialize key to high-values

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.