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



That is exactly what I'm doing. I don't need to know the minimum value, just
the top 10 (selectable by the user from 1-99). I know I posted a lot of
code, here are the relevant pieces to your point:

d toplistcount s 5i 0 inz(0)
d ds
d toplist 90 dim(1000) descend
d topdept inz like(sqlrow.department)
d overlay(toplist:1)
d topitem inz like(sqlrow.item)
d overlay(toplist:*next)
d topdesc inz like(sqlrow.item_desc)
d overlay(toplist:*next)
d topqty inz
d like(sqlrow.dr_qty)
d overlay(toplist:*next)
d topcost inz
d like(sqlrow.ext_cost)
d overlay(toplist:*next)

and

sorta %subarr(topqty:1:toplistcount);
wrtsection('topqtyheader');
for i = 1 to workrank;
if i <= toplistcount;
updhtmlvar('topqtyitem':topitem(i));
...
wrtsection('topqtydetail');
endif;
endfor;
sorta %subarr(topcost:1:toplistcount);
wrtsection('topcostheader');
for i = 1 to workrank;
if i <= toplistcount;
updhtmlvar('topcostitem':topitem(i));
...

All the entries I am interested in are in the range of 1 to toplistcount.
Since the array is bounded and I am checking bounds on insert, this sorta
restricts to the actual data set - no need to worry about false sort values.


My issue is I have two arrays that are identical in structure, how could I
use one piece of code to report over it, instead of two (or four). Simon's
suggestion appears to be what I was thinking about.

Thanks,
Loyd


On Thu, Apr 23, 2009 at 5:41 PM, <Asher613Smith@xxxxxxx> wrote:

Again, SORT to the rescue. If you define the array over a data structure,
each element of which has both fields. then you can sort the array
descending once by the first field (cost),
and elements 1 - 10 will have the 10 top costs. Then sort the array a
second time by the quantity descending, and elements 1-10 will have the 10
top
quantities.



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.