Skip to Main Content
IBM Power Ideas Portal


This portal is to open public enhancement requests against IBM Power Systems products, including IBM i. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Delivered
Workspace IBM i
Categories Languages - RPG
Created by Guest
Created on Feb 16, 2018

Support Array names and %SUBARR on %MIN and %MAX in RPG IV

The IBM i v7r2 RPG IV enhancements of %MIN and %MAX do not support the use of an RPG ARRAY name as their only parameter. This would provide the ability to extract the min/max of an array of elements. Supporting an array name as well as %SUBARR would make %MIN and %MAX much more useful.


Use Case:

A typical program loads 100 elements of data into an array. Today the RPG developer would need to use myMin = %MIN(arr(1) : arr(2) : arr(3) : arr(4) : [repeat 100times]);

This syntax is not practical. If arrays were supported, the RPG developer in that same context could specify:
myMin = %MIN( arr );
or if say... only 35 elements were used:
myMin = %MIN( %SUBARR(arr : 1 : 35) );

Which goes without saying is much easier to code vs the current method which is basically unusable with arrays.


Idea priority Medium
  • Guest
    Reply
    |
    Sep 8, 2021

    IBM believes that the request described has been solved and is available with new built-in functions %MAXARR and %MINARR. These built-in functions are available for 7.3 and 7.4 with PTFs.

    For 7.3, you need PTF 5770WDS SI77165.

    For 7.4, you need PTF 5770WDS SI77166.

    For 7.4 TGTRLS(V7R3M0), you need PTF 5770WDS Si77167.

    For more information, see https://www.ibm.com/support/pages/node/6481909.

  • Guest
    Reply
    |
    Sep 22, 2020

    The CAAC has reviewed this requirement and recommends that IBM view this as a medium priority requirement that should be addressed. It would be cleaner and easier to code, to name an array rather than the individual elements of it, in a min or max function. In addition, receiving the position of the min or max value might help in aligning that value with something in a different array, such as for an employee name array, for example.

    Background: The COMMON Americas Advisory Council (CAAC) members have a broad range of experience in working with small and medium-sized IBM i customers. CAAC has a key role in working with IBM i development to help assess the value and impact of individual RFEs on the broader IBM i community, and has therefore reviewed your RFE.

    For more information about CAAC, see www.common.org/caac

    For more details about CAAC's role with RFEs, see http://www.ibmsystemsmag.com/Blogs/i-Can/May-2017/COMMON-Americas-Advisory-Council-%28CAAC%29-and-RFEs/

    Nancy Uthke-Schmucki - CAAC Program Manager

  • Guest
    Reply
    |
    Aug 17, 2020

    Hi Vern. Yes, you could use the result of %maxarr as your array index. :-)

  • Guest
    Reply
    |
    Aug 17, 2020

    Barbara, could things be nested, as with other functions? So that one could use this statement -

    maxval = arr(%maxarr(arr));

    Hope this isn't a Captain Obvious kind of thing!

  • Guest
    Reply
    |
    Apr 17, 2020

    IBM will use this request as input to planning but no commitment is made or implied. This request will be updated in the future if IBM implements it. IBM will use votes and comments from others in the community to help prioritize this request.

    If this request is implemented, it will most likely be in the form of %MAXARR and %MINARR built-in functions that return the index of an element with the maximum or minimum value in the array.

  • Guest
    Reply
    |
    Nov 8, 2018

    RPG built-in functions that can be used in expressions don't have parameters that get modified. If this extra parameter was not added you could code like this:

    maxval = %maxarr(arr);
    index = %lookup(maxval : arr);

    But rather than have an extra parameter to receive the index, the built-in functions could just return the index instead of returning the maximum or minimum value.

    index = %maxarr(arr);
    maxval = arr(index);

    It would be interesting to see some real-life suggestions of how RPG programmers would use these built-in functions. Would it be more usual to just want the value, or would it be more usual to want to know which element has that value?

  • Guest
    Reply
    |
    Nov 5, 2018

    Would it be useful to have another optional parameter to the bif to get the element of the array with the min or max value?
    Such as an array {10, 20, 50, 10}, %maxarr would return 50, and this new parm would get 3. And %minarr would give 1, as that is the first element with the minimum value.

  • Guest
    Reply
    |
    Nov 5, 2018

    Would it be useful to have another optional parameter to the bif to get the element of the array with the min or max value?
    Such as an array {10, 20, 50, 10}, %maxarr would return 50, and this new parm would get 3. And %minarr would give 1, as that is the first element with the minimum value.

  • Guest
    Reply
    |
    Jul 6, 2018

    IBM has received the requirement and is evaluating it. IBM will provide a response after evaluation is complete.

  • Guest
    Reply
    |
    Mar 5, 2018

    Hi Bob, I get your point, but it would be inconsistent with other built-in functions, like %SUBARR, that have start and length/number parameters. So, if these built-ins ever get implemented, you'll have to code that "1" for the starting_elem if you want to specify the number of elements.

  • Guest
    Reply
    |
    Feb 16, 2018

    Hi Barbara,
    Yes %MinARR() could have 1, 2 or 3 parameters.

    %MAXARR( myArr_or_DSArr [ : max_elems ]);
    %MAXARR( myArr_or_DSArr : starting_elem : max_elems);

    I suggest this because I'm always partially filling an array and have on only 1 occasion had an array where I started filling it at index X instead of 1. Of course I know "18 people" have code that starts from something other than 1, but I prefer to satisfy the overwhelming/vast majority with %MAXARR( arr : max_elems); and make the exception situations work for it. Thanks for the consideration.

  • Guest
    Reply
    |
    Feb 16, 2018

    To fully support arrays, including getting the maximum or minimum value of a subfield in a data structure array (the maximum or minimum of dsarray(*).subfield), the syntax would have to be quite different from the syntax %MAX and %MIN. So a different set of built-in functions, such as %MAXARR and %MINARR, would probably be used for arrays.