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 Apr 24, 2019

Enhancement to SELECT

Currently there is no difference between a SELECT ... ENDSL block and an IF ... ELSEIF ... ENDIF block. I am not real sure why both are in the language. However, if the SELECT block had a "switched" format like the SWITCH block in C, that would be useful. I envision something like this:

SELECT <expression>
WHERE <constant/list/expression>
<code>
WHERE <constant/list/expression>
<code>
... (unlimited WHERE statements)
OTHER
<code>
ENDSL

Features:
- No break necessary
- WHERE could specify a constant, or expression that must match the results of the expression on the SELECT
- WHERE could specify a list of constants (separated by colon :), one of which must match the results of the expression on the SELECT
- Evaluation stops at the first WHERE which matches SELECT


Use Case:

This would make checking code values easier, with less duplicated code:

Select fb.aidByte;
Where CF03:CF12;
return fb.aidByte;
Where CF04;
Prompt();
Where CF06;
Add();
Where CF05;
Refresh();
Other;
ProcessScreen();
Endsl;


Idea priority Medium
  • Guest
    Reply
    |
    May 20, 2023
    IBM believes that the solution for the Idea described is available with PTFs provided at the same time as the Spring 2023 Technology Refresh.

    An operand is now allowed for the SELECT statement, and two new operation codes, WHEN-IN and WHEN-IS, are added for comparison with the SELECT operand.

    For documentation on this enhancement, see

    - What's new since 7.5: https://www.ibm.com/docs/en/ssw_ibm_i_75/rzasl/rpgrelv7r5post.htm
    - What's new since 7.4: https://www.ibm.com/docs/en/ssw_ibm_i_74/rzasl/rpgrelv7r4post.htm

    For information about the PTFs you need for this enhancement, see https://www.ibm.com/support/pages/node/6982199

    - IBM Power Systems Development
  • Guest
    Reply
    |
    Dec 22, 2022

    I think it is extremely important, to make the select statement more useful, that the evalutation of the "left side" expression is only done once, so code like this will work:

    select precedureCall(parameter);
    when *zero;
    // OK
    when in %range(1:9);
    // low error
    when in %list(10:11:12);
    // medium error
    when in %range(*loval:-1);
    // negativ error
    other;
    // something else
    endsl;

    So the procedure is only called once, and the resulting value can be compared to different cases.

    At best, %range and %list should be supported, because this makes code much clearer - even if it differs from SQL syntax.

  • Guest
    Reply
    |
    Jul 11, 2022

    You can go even beyond pure C-styled switch statements.

    Also string matching (matching directly to a string).

    Or full pattern matching with guards and even destructuring (ie. matching on a full DS), inspired by language like Haskell or Scala (this would be nice).



  • Guest
    Reply
    |
    Apr 29, 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.

  • Guest
    Reply
    |
    Feb 25, 2020

    The CAAC has reviewed this requirement and recommends that IBM view this as a medium priority requirement that should be addressed. This would create consistency with the way SQL handles the CASE predicate.

    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 6, 2019

    The COMMON Europe Advisory Council (CEAC) has reviewed this requirement and recommends that IBM view this as a medium priority requirement that should be addressed.

    Background: The CEAC members have a broad range of experience in working with small and medium-sized IBM i customers. CEAC has a crucial 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.

    To find out how CEAC help to shape the future of IBM i, see CEAC @ ibm.biz/BdYSYj and the article "The Five Hottest IBM i RFEs Of The Quarter" at ibm.biz/BdYSZT

    Therese Eaton – CEAC Program Manager, IBM

  • Guest
    Reply
    |
    Jun 17, 2019

    Why not make it a SWITCH opcode after all? Especially valuable would be that the expression in the SELECT/SWITCH statement can also be a function (return value).

  • Guest
    Reply
    |
    Jun 7, 2019

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

    If this is implemented, it will almost certainly be an overload of the SELECT operation code. If the SELECT opcode has an operand, the WHEN opcode will have a single operand rather than a logical expression.

  • Guest
    Reply
    |
    May 29, 2019

    I first saw the CASE statement in Pascal, and would find it quite useful in RPG. It more clearly conveys the "parallel" nature of the tests (while the SELECT statement's WHEN clauses might contain wildly different conditions).

  • Guest
    Reply
    |
    May 9, 2019

    The standard SQL procedure language and Db2 support a CASE statement the provides the same capability. For example:
    CASE v_workdept
    WHEN 'A00' THEN UPDATE department SET deptname = 'DATA ACCESS 1';
    WHEN 'B01' THEN UPDATE department SET deptname = 'DATA ACCESS 2';
    ELSE UPDATE department SET deptname = 'DATA ACCESS 3';
    END CASE

  • Guest
    Reply
    |
    Apr 30, 2019

    Yes - just like PL/1 :)

  • Guest
    Reply
    |
    Apr 25, 2019

    I've wanted this for a long time and actually tend to use SELECT only in these kinds of cases. I'm not sure though that overloading SELECT like this is the best approach. As the requestor notes SWITCH is used in other languages and I'd rather see a new op-code implemented for RPG.

  • Guest
    Reply
    |
    Apr 25, 2019

    I've wanted this for a long time and actually tend to use SELECT only in these kinds of cases. I'm not sure though that overloading SELECT like this is the best approach. As the requestor notes SWITCH is used in other languages and I'd rather see a new op-code implemented for RPG.