I believe the other two responders probably have something there.
The logic looks like someone who loves fixed format and only uses free format if they absolutely have to. Such as certain functions not available in fixed format.

I have a tough time understanding a read loop of the customer master file based on the customer key, which I assume is the customer number. Is it likely you have duplicate customer numbers? Or would a chain have worked better?

Then the big picture view has me wondering if you are looking for all customers who may have a substring in their name. Perhaps a customer lookup function? In that case I might use SQL and a cursor:
D Stmt1 s 512a varying
D SearchString s 50a varying
Stmt1 = 'select cusnbr, cmname from cusmst where cmname like ?';
// The 'like' function, with a string surrounded by % signs, is your midstring search
SearchString = '%' + %trim(neword) + '%';
Exec sql declare C1 cursor for SqlStmt;
Exec sql prepare SqlStmt from Stmt1;
Exec sql Open C1 using SearchString;
Exec sql fetch c1 into :cusnbr, :cmname; // Priming read of loop
Dow sqlcode = *zeros;
// logic here to fill subfile of results
Exec sql fetch c1 into :cusnbr, :cmname; // get next row
EndDo; // found all matching rows.
Exec sql close C1;


And if you want to get fancy you can even do a "sounds like". For more information see the following:
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/db2/rbafzscasound.htm

Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.