|
I recently used the following logic to approach a similar problem: Using 3 subscripts, sub, suba and sub b. I move the value I am searching for, "JOHN" in your example, into a variable REPLACE-IT (PIC X(30)) and the string I am looking for the value in into SRCDTA-80 (PIC x(80)), then do the following: MOVE ZEROS to FOUND-IT Perform 2420-inspect-it thru 2420-exit Varying sub from 1 by 1 until sub > 30. 2420-inspect-it. compute suba = 30 - sub. compute subB = sub - 1. if replace-it(sub:suba) = spaces INSPECT SRCDTA-80 TALLYING FOUND-IT FOR ALL REPLACE-IT (1:subB) move 31 to sub end-if. 2420-EXIT. EXIT. The routine removes the trailing spaces from the variable replace-it and then looks for that variable in the string SRCDTA-80. If the variable FOUND-IT (PIC S9(3)) has a value greater than zero, then REPLACE-IT was found in SRCDTA-80. John A Arnold (301) 214-8939 jarnold@xxxxxxxxxxxxx -----Original Message----- From: cobol400-l-request@xxxxxxxxxxxx [mailto:cobol400-l-request@xxxxxxxxxxxx] Sent: Monday, August 16, 2004 1:01 PM To: cobol400-l@xxxxxxxxxxxx Subject: COBOL400-L Digest, Vol 2, Issue 87 Send COBOL400-L mailing list submissions to cobol400-l@xxxxxxxxxxxx To subscribe or unsubscribe via the World Wide Web, visit http://lists.midrange.com/mailman/listinfo/cobol400-l or, via email, send a message with subject or body 'help' to cobol400-l-request@xxxxxxxxxxxx You can reach the person managing the list at cobol400-l-owner@xxxxxxxxxxxx When replying, please edit your Subject line so it is more specific than "Re: Contents of COBOL400-L digest..." Today's Topics: 1. Green-screen search argument (Jay Sulzmann) 2. RE: Green-screen search argument (Winchester Terry) 3. Re: Green-screen search argument (Jay Sulzmann) 4. Re: Green-screen search argument (Jay Sulzmann) 5. RE: Green-screen search argument (Winchester Terry) 6. Conversion of numeric data to character format? (Jay Sulzmann) ---------------------------------------------------------------------- message: 1 date: Mon, 16 Aug 2004 09:43:09 -0400 from: "Jay Sulzmann" <jsulzmann@xxxxxxxxxxx> 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. ------------------------------ message: 2 date: Mon, 16 Aug 2004 09:57:42 -0400 from: Winchester Terry <terry.winchester@xxxxxxxxxxxxxxx> subject: RE: [COBOL400-L] Green-screen search argument Another option would be to call the QCLSCAN API. > -----Original Message----- > From: cobol400-l-bounces@xxxxxxxxxxxx > [mailto:cobol400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jay Sulzmann > Sent: Monday, August 16, 2004 9: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. > ------------------------------ message: 3 date: Mon, 16 Aug 2004 10:14:41 -0400 from: "Jay Sulzmann" <jsulzmann@xxxxxxxxxxx> subject: Re: [COBOL400-L] Green-screen search argument Terry, According to IBM's documentation, maximum length of field-to-be-scanned (parameter 1) is 999. Got that. What is the maximum length of the pattern argument (parameter 4)? Thanks -- Jay ----- Original Message ----- From: "Winchester Terry" <terry.winchester@xxxxxxxxxxxxxxx> To: "'COBOL Programming on the iSeries/AS400'" <cobol400-l@xxxxxxxxxxxx> Sent: Monday, August 16, 2004 9:57 AM Subject: RE: [COBOL400-L] Green-screen search argument > Another option would be to call the QCLSCAN API. > > > -----Original Message----- > > From: cobol400-l-bounces@xxxxxxxxxxxx > > [mailto:cobol400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jay Sulzmann > > Sent: Monday, August 16, 2004 9: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. > > > _______________________________________________ > 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. > > ------------------------------ message: 4 date: Mon, 16 Aug 2004 10:46:22 -0400 from: "Jay Sulzmann" <jsulzmann@xxxxxxxxxxx> subject: Re: [COBOL400-L] Green-screen search argument Thanks, Terry - that worked nicely. Compared to INSPECT, relatively painless. --Jay ----- Original Message ----- From: "Winchester Terry" <terry.winchester@xxxxxxxxxxxxxxx> To: "'COBOL Programming on the iSeries/AS400'" <cobol400-l@xxxxxxxxxxxx> Sent: Monday, August 16, 2004 9:57 AM Subject: RE: [COBOL400-L] Green-screen search argument > Another option would be to call the QCLSCAN API. > > > -----Original Message----- > > From: cobol400-l-bounces@xxxxxxxxxxxx > > [mailto:cobol400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jay Sulzmann > > Sent: Monday, August 16, 2004 9: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. > > > _______________________________________________ > 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. > > ------------------------------ message: 5 date: Mon, 16 Aug 2004 11:00:39 -0400 from: Winchester Terry <terry.winchester@xxxxxxxxxxxxxxx> subject: RE: [COBOL400-L] Green-screen search argument Jay, This is a copy of the working-storage area that I use. Since it's a pointer to a character string, I use the same length as the charaacter-string being scanned. Since the pattern length cannot be longer than the string being scanned it standsto reason that the character-pattern must be <= the string size (IMO). Hope this helps Terry *---------------------------------------------------------------* * Parameter area for QCLSCAN * *---------------------------------------------------------------* * Define longest string you intend to scan * and move it to here 01 character-string pic x(112) value spaces. * Set this to the length of string that * you placed in character-string 01 string-len pic s9(3) value +112 comp-3. * Set this to the position you want to * start scanning for a pattern 01 start-pos pic s9(3) value +1 comp-3. * define longest pattern you intend to use * and move the pattern here 01 character-pattern pic x(112) value spaces. * Set this to the length of the pattern * you placed in character-pattern 01 pattern-len pic s9(3) value +0 comp-3. * Set this to "1" to translate your * character-string to Upper case first * -before- the scan begins 01 translate-char pic x(1) value '1'. * Set this to "1" to trim all trailing * blanks from character-string -before- * the scan begins 01 trim-blanks pic x(1) value '1'. * Set this to a "wildcard" value contained * in your pattern, to avoid mis-matches 01 wildcard-char pic x(1) value space. * Set by QCLSCAN to a value as follows: * Set by QCLSCAN to a value as follows: * --> GT 0 = Position in the string * --> 0 = Pattern not found * --> -1 = Pattern longer than string * --> -2 = Pattern length is LT 1 * --> -3 = 1st char in pattern is a * wildcard character * --> -4 = Pattern is blank and the * trim-blanks is a 1 * --> -5 = Starting position not valid 01 return-result pic s9(3) value +0 comp-3. call 'QCLSCAN' using character-string string-len start-pos character-pattern pattern-len translate-char trim-blanks wildcard-char return-result if return-result < +1 Perform action for a No-Find condition end-if > -----Original Message----- > From: > cobol400-l-bounces+terry.winchester=raymondcorp.com@xxxxxxxxxx > om > [mailto:cobol400-l-bounces+terry.winchester=raymondcorp.com@mi > drange.com] On Behalf Of Jay Sulzmann > Sent: Monday, August 16, 2004 10:15 AM > To: COBOL Programming on the iSeries/AS400 > Subject: Re: [COBOL400-L] Green-screen search argument > > > Terry, > > According to IBM's documentation, maximum length of > field-to-be-scanned > (parameter 1) is 999. Got that. > What is the maximum length of the pattern argument (parameter 4)? > > Thanks -- Jay > > ----- Original Message ----- > From: "Winchester Terry" <terry.winchester@xxxxxxxxxxxxxxx> > To: "'COBOL Programming on the iSeries/AS400'" > <cobol400-l@xxxxxxxxxxxx> > Sent: Monday, August 16, 2004 9:57 AM > Subject: RE: [COBOL400-L] Green-screen search argument > > > > Another option would be to call the QCLSCAN API. > > > > > -----Original Message----- > > > From: cobol400-l-bounces@xxxxxxxxxxxx > > > [mailto:cobol400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jay Sulzmann > > > Sent: Monday, August 16, 2004 9: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. > > > > > _______________________________________________ > > 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. > > > > > > > _______________________________________________ > 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. > ------------------------------ message: 6 date: Mon, 16 Aug 2004 11:28:22 -0400 from: "Jay Sulzmann" <jsulzmann@xxxxxxxxxxx> subject: [COBOL400-L] Conversion of numeric data to character format? Dear COBOL experts, Is there any equivalent of the following in COBOL, or an easier way to do it than fooling around with numeric-edited fields? CustNbr is a 6-digit signed (USAGE IS DISPLAY) field. I want to put the Customer Number (CustNbr) into message data (MessageData) to pass to the QMHSNDPM API. If the customer number is 123,and I do the following using free-format RPG-IV, MessageData = %char( CustNbr ); the input is 000123 and the output would be 123 (left-justified and all). The message looks like Customer Number 123 is not on file. The only way I know how to do this in COBOL results in Customer Number 123 is not on file. 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) digest 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. End of COBOL400-L Digest, Vol 2, Issue 87 *****************************************
As an Amazon Associate we earn from qualifying purchases.
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.