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



Charles, let me make sure I understand the business requirement.  

1. You have a subfile which contains a list of entries, the pertinent
information being that the zipcode is unique.

2. You wish to add an entry.  When you do, you want to make sure it isn't
already in the list.

What's not clear is:

A. Is there more information in the subfile besides the zipcode?

B. When you add a new entry, do you want it to be added in sequence or at
the bottom of the list?

If the answer to (A) is "No" and the zipcode is a 5-digit numeric value,
then I'd probably just create four arrays of 25000 1-char values.  Divide
the zipcode by 25000 to select the array, and use the remainder as the index
(you'll have to do a little magic because RPG arrays are one-based rather
than zero-based).  If the value is blank, the zipcode is not in the subfile.
If the value is non-blank, an entry for this zipcode already exists.  Set
the value whenever you add a zipcode.

The nice thing about this approach is that if the answer to (B) is "in
sequence", then you can just spin through the arrays to repopulate the
subfile.

If you have more data than this, though, (the answer to (A) is "Yes"), then
this technique probably won't work because you'd have to have four
additional arrays for the other data, and if that data has any size at all
it could take up a lot of memory.  In that case, I'd probably suggest an
array of 9999 elements (the maximum in a subfile) and use LOOKUP to check
for duplicate entries (and QSORT to sort them as needed).

Joe



> From: Charles St-Laurent
> 
> I want to fill a customer subfile by adding a record only if the zip code
> is
> not in what I've filled until now in the subfile. Is it possible to
> declare
> a subfile with a key on a particular field of the subfile, so I will be
> able
> to chain in my RPG ILE program to find this particular value? Or must I
> scan
> all the subfile record by record to verify the presence of the searched
> zip
> code?


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.