× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Jay,

  As a method to solve your task using INSPECT, you must use reference 
modification to set the length of the search argument since it will vary.  The 
first PERFORM is just used to determine the length of the length of the data 
without the trailing spaces.  In the example below, define L and S as numeric 
subscripts of adequate length and SEARCH-ARG as a alphanumeric field that holds 
the value you are searching for.  The WS-SEARCH-ARG-FOUND is just a switch 
field to indicate the results.  FS-COBOL-NAME is the field that is being 
searched.

WORKING-STORAGE.
           01  FS-COBOL-NAME           PIC X(30).
           01  WS-SEARCH-ARG-FOUND         PIC X   VALUE 'N'.
               88  SEARCH-ARG-FOUND                VALUE 'Y'.
           01  S                           PIC S9(5) VALUE +0.
           01  L                           PIC S9(5) VALUE +0.
PROCEDURE DIVISION.
                    MOVE 'N' TO WS-SEARCH-ARG-FOUND
                    PERFORM VARYING L FROM 30 BY -1 UNTIL
                             SEARCH-ARG(L:1) NOT = SPACE OR
                             L = 1
                    END-PERFORM
                    MOVE ZERO TO S
                    INSPECT FS-COBOL-NAME(FS-IDX)
                        TALLYING S FOR ALL
                        SEARCH-ARG(1:L)
                    IF S > ZERO
                        MOVE 'Y' TO WS-SEARCH-ARG-FOUND
                    END-IF

-----Original Message-----
From: Jay Sulzmann [mailto:jsulzmann@xxxxxxxxxxx]
Sent: Monday, August 16, 2004 8:43 AM
To: COBOL Programming on the iSeries/AS400
Subject: [COBOL400-L] Green-screen search argument


Good morning,

Suppose in a subfile app I want to list only the entries that contain a 
specific string value and filter out all others. For example, I want to list 
only the customers that have "JOHN" in their name.

The search-argument is "JOHN" and the application needs to display "JOHN 
SMITH", "BIG-JOHN", "SALLY JOHNSON". Suppose the Customer Name is 30 bytes 
long. How do I construct an INSPECT operation so that it looks at the customer 
name for the string "JOHN" without including the 26 blanks?

Cheers. -- Jay

=================================
Jay Sulzmann
AS/400 Senior Programmer/Analyst
AS/400 Certified RPG IV Developer
 
Hainey Business Systems LLC
8 East Canal Street
Dover, PA  17315
 
Tel:  717-718-9601 Ext. 231
Fax:  717-292-9474
AIM: bluejay0827 
Web: www.hbs-inc.com
____________________________________
Providing E-Business, EDI, AS/400
Development and related services nationwide.
_______________________________________________
This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing list
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/cobol400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.