× 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.



Lim,

Another alternative would be initially load the data from CUSTL1 into an
array, which you could sort however you want and display in the subfile. If
(and only if) a user actually updates the data, you chain to the record
(using the customer number from the array element), check no other user has
changed it since it was loaded into the array, and update that record in
CUSTL1.

In this case, you only need to define a single LF, and instead of all the
CHAIN's, you simply do a LOOKUP (optionally defining the array as ASCEND and
sorting the array immediately before the LOOKUP to enable RPG to do a binary
search).

Not necessarily 'better', and probably not a possibility if there are more
than 32767 records in the file (max # of array elements) unless you want to
get creative with qsort/bsearch, but it avoids the specific problem you're
having...

Rory

On Tue, Aug 17, 2010 at 11:56 AM, hockchai Lim <
lim.hock-chai@xxxxxxxxxxxxxxx> wrote:

ok. I guess my OP is not stating my problem too clear. Sorry about that.
2nd try:

Let's assume that I've green screen app that allows user to pull up
customer
record in serveral different ways, by customer #, by Creditcard #, by
SSN....
I order to lookup the customer record base on whichever lookup method user
used on the screen, I would need to have two or more customer master
logical
files (one for each lookup method) on F spec. After using the proper
logical file to lookup customer record, the program displays the customer
record to the user, user then updates the info on the screen and press
enter. The RPG program then validates it and update the Customer record.

If I don't use qualified result-field DS, then everything is business as
usual. Since fields in all those different logical files are global and
there is only one set them, It does not matter which logical file the
program uses to lookup the customer record. The same set of fields are
populated after a sucessful chain. Again, since there is only one set of
fields, I can freely use then without regard to which logical the program
has used to chain.

in this case, the RPG program would look like this:

if customer# <> 0;
chain (customer#) CUSTL1;
elseif creditcard# <> 0;
chain (creditcard) CUSTL2;
elseif ssn <> 0;
chain (ssn) CUSTL3;
. . .
endif;

ScreenField_CustName = CUSTNAM;

exfmt mainScreen;

CustNam = ScreenField_CustName;

chain (CUST#) CUSTL0 tmpCUST;
update CUSTL0;


How/what would be the best way to handle above if I prefer to always use
result-field DS when performing file IO opcode?


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.