David,

You might also consider creating a temporary table in Db2, and then load the entire array into the temp table, and then you can use the full power of SQL to query the temp table, and create a "results set" containing only the subset that you are interested in.   And, when done, you can just DROP the temp table.

I think this should be much easier and more straight-forward than your proposed "enhancement" to RPG IV.

All the best,

Mark S. Waterbury


On Tuesday, November 4, 2025 at 01:36:03 PM EST, David Gibbs via RPG400-L <rpg400-l@xxxxxxxxxxxxxxxxxx> wrote:





So I submitted a enhancement request to the Ideas site to add a built in
function to subset an array using a procedure to determine if the array
element should be included.

https://ibm-power-systems.ideas.ibm.com/ideas/IBMI-I-4699

Create a new built in function to subset an array using a procedure to
filter.

Similar to the %SUBARR function, but allow a procedure to be specified to
determine if the array entry should be included in the result.

Something like ...

dcl-ds arraySpec_t qualified template;
  subField1 char(10);
  subField2 char(10);
end-ds;

dcl-ds newArray likeds(arraySpec_t);
dcl-ds oldArray likeds(arraySpec_t);
.
.
newArray = %FILTERARR(oldArray:1:%elem(oldArray):filterProc);
.
.
.
dcl-proc filterProc;
  dcl-pi *n ind;
    entry likeds(arraySpec_t) const;
  end-pi;
  return entry.subField1 = 'xyz';
end-proc;


Any comments on this?

david


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