Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SEARCH ALL help. 1

Status
Not open for further replies.

wolves

Programmer
Jan 26, 2001
130
US
Could not find anything on my particular problem during a search. Have a problem during a SEARCH ALL on a mainframe.
Want to do something like this:

Code:
    SEARCH  ALL  WS-TBL
      AT END
        SET  WS-NOT-FND-ON-LIST TO TRUE
      WHEN WS-TABLE-NUM(WS-INDX) EQUAL WS-CHECK-NUM
       AND WS-TABLE-SUFF(WS-INDX) EQUAL WS-CHECK-SUF
       AND (WS-TABLE-ACCT(WS-INDX) EQUAL WS-VALID-NUM1 OR
            WS-TABLE-ACCT(WS-INDX) EQUAL WS-VALID-NUM1 OR
            WS-TABLE-ACCT(WS-INDX) EQUAL WS-VALID-NUME2 OR
            WS-TABLE-ACCT(WS-INDX) EQUAL WS-VALID-NUME2)
        SET  WS-DOC-FND-ON-LIST     TO  TRUE
     END-SEARCH.
But get an error:
Code:
2398  IGYPS2051-S   "(" WAS FOUND IN A "WHEN" PHRASE OF A "SEARCH ALL" STATEMENT.  THE "SEARCH ALL" STATEMENT WAS DISCARDED.

Is there are ideas around this? I really need to check the condition inside the ( ) also, and would like to check it once, or am I going to have to do a SEARCH ALL 4 times, one for each of my 4 WS fields (WS-VALID-NUMxx)?
 
You are not allowed to have OR logic in a SEARCH ALL. WS-TABLE-NUM, WS-TABLE-SUFF, and WS-TABLE-ACCT must each be objects of an ASCENDING/DESCENDING KEY specified for WS-TBL. If we could see your table definition, we might be able to provide additional assistance, but it looks like you'll need four SEARCH ALLs or have to consider modifying your approach somewhat.

Regards.

Glenn
 
Or depending on whether your table def can be tweaked, you can duplicate the SEARCH ALL logic rather readily. Like the prior poster says, give us some details and we can suggest where to go from there.
 
Here is my table definition.

Code:
05 WS-DOC-TBL
    OCCURS  1 TO 20000  TIMES
    DEPENDING  ON  WS-DOC-ENTRIES
    ASCENDING KEY  IS  WS-TABLE-NUM, WS-TABLE-SUFF,
                       WS-TABLE-ACCT
    INDEXED  BY  WS-DOC-INDX   WS-DOC-MAX.
  10  WS-TABLE-NUM         PIC X(12) VALUE SPACES.
  10  WS-TABLE-SUFF        PIC X(02) VALUE SPACES.
  10  WS-TABLE-DATE        PIC X(08) VALUE SPACES.
  10  WS-TABLE-ACCT        PIC X(04) VALUE SPACES.

I really need to find a match with WS-TABLE-NUM and WS-TABLE-SUFF and WS-TABLE-ACCT against my input file, which will have INPUT-TABLE-NUM, INPUT-TABLE-SUFF, and 4 different INPUT-TABLE-ACCT values.

I thing everyone is right, I will have to end up doing 4 search all's since I cannot use 'OR' in the search all, and the last fied INPUT-TABLE-ACCT will have 4 separate values which have to be checked each time.


 
Hmmm....
Four SEARCH ALLs will definitely solve your problem and is very straightforward. Another approach you might consider is to redefine your table as follows:
Code:
05 WS-DOC-TBL
    OCCURS  1 TO 5000  TIMES
    DEPENDING ON  WS-DOC-ENTRIES
    ASCENDING KEY WS-TABLE-NUM 
                  WS-TABLE-SUFF
    INDEXED BY    WS-DOC-INDX
                  WS-DOC-MAX.
  10  WS-TABLE-NUM         PIC X(12) VALUE SPACES.
  10  WS-TABLE-SUFF        PIC X(02) VALUE SPACES.
  10  WS-TAB-ENTRY
      OCCURS 4 TIMES 
      INDEXED BY WS-DOC-INDX2.
      15  WS-TABLE-DATE        PIC X(08) VALUE SPACES.
      15  WS-TABLE-ACCT        PIC X(04) VALUE SPACES.
Use SEARCH ALL to find the proper WS-TABLE-NUM/WS-TABLE-SUFF entry and then a linear search to find the proper WS-TABLE-ACCT. Theoretically, this search should be faster than 4 SEARCH ALLs for random values; actual results may be different.

Glenn
 
Wait a minute - I'm not sure I understand what you're doing...

For your search, WS-TABLE-NUM and WS-TABLE-SUFF are your keys. Then there are 4 different WS-TABLE-DATE and WS-TABLE-ACCTs with the same WS-TABLE-NUM and WS-TABLE-SUFF?

If so, redefining the table as 3gm suggests is the way to do it.

If the table must be maintained the other way, I have a couple of ideas beyond simply firing off four SEARCH ALLs.
 
Actually,
I have to check WS-TABLE-NUM to 1 field in my input file.
I have to check WS-TABLE-SUFF to 1 field in my input file.
I have to check WS-TABLE-ACCT to 4 fields in my input file.
I have to check WS-TABLE-NUM to 1 field in my input file.

THE WS-TABLE-DATE gets moved when I meet my match criteria above.

What I thought now was just to do this:
Code:
SEARCH  ALL  WS-TBL
      AT END
        SET  WS-NOT-FND-ON-LIST TO TRUE
      WHEN WS-TABLE-NUM(WS-INDX) EQUAL WS-CHECK-NUM
       AND WS-TABLE-SUFF(WS-INDX) EQUAL WS-CHECK-SUF
      SET  WS-FND-ON-LIST     TO  TRUE
END-SEARCH.

IF WS-FND-ON-LIST     
   IF WS-TABLE-ACCT(WS-INDX) EQUAL WS-VALID-NUM1 OR
      WS-TABLE-ACCT(WS-INDX) EQUAL WS-VALID-NUM2 OR
      WS-TABLE-ACCT(WS-INDX) EQUAL WS-VALID-NUME1 OR
      WS-TABLE-ACCT(WS-INDX) EQUAL WS-VALID-NUME2
      SET  WS-NUM-ON-LIST     TO  TRUE
   ELSE 
      SET  WS-NOT-FND-ON-LIST     TO  TRUE
   END-IF
ELSE 
    SET  WS-NOT-FND-ON-LIST     TO  TRUE
END-IF

So I get my initial check out the way, then check my WS-TABLE-ACCT against each of the 4 fields, set a new flag and go on.

 
Sounds like you've got it figured out. So WS-TABLE-ACCT is NOT part of the table key and WS-TABLE-NUM and WS-TABLE-SUFF are UNIQUE keys to the table? If not, it seems to me that you still have some issues.

Glenn.
 
That's correct. WS-TABLE-ACCT is not part of the table key, but WS-TABLE-NUM and WS-TABLE-SUFF are UNIQUE keys.

I was first confused thinking that I had to use WS-TABLE-ACCT as a key, but not the case.

Thanks again for all the help. Will remember this for next time this comes up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top