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



You can't do a look up on a multiple occurrence data structure as far as I
know. To do a look up use an array of records.

Also makes no sense to use a loop to load your structure. Just use a
multiple row fetch to load everything in one call. Works with an array of
records also.


On Wed, Nov 18, 2009 at 2:42 PM, Timothy Adair <tadair@xxxxxxxxxxxxxxxx>wrote:

I've searched the archives and can't find an answer on this. How do you do
a Lookup in a multiple-occurrence data structure. This is my first one and
I can't seem to find a (good) solution.

Here's my DS:

D Record ds occurs(2000)
D Comp# 4 0
D Prod# 7 0
D CurDat 8 0
D CurPrc 7 4
D Status 1
D GL# 7 0

I am populating this with an SQL cursor loop, and doing Order By the last
field, GL#. Now I need to be able to do some kind of lookup on the GL#
field and return the element number that gets the hit.

I know I can do something funky, like do a loop that checks each occurrence
of the GL# field, or pull the GL# field out of the DS and make it its own
array (both ugly), but isn't there a built-in function for this? I tried
%lookup but that doesn't compile if it's not an array.

Help? (TIA.)

--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



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.