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 Not under consideration
Workspace IBM i
Categories Languages - RPG
Created by Guest
Created on Jul 30, 2019

Allow 3rd parameter of %subst() to exceed length of string

Currently, if I use something like this:

DNKYWD = %subst(NARR: 1: 10);

when NARR is defined in the procedure interface like this:

NARR Varchar(32740) const options(*varsize);

I don't know how long NARR really is unless I check it. This causes an issue where I might get RNX0100 - Length or start position is out of range for the string operation.

The only way to deal with this is to use a much more complex expression:

DNKYWD = %subst(NARR: 1: %min(10: %len(NARR)));

This is way less readable than the first line of code above, and therefore more error prone.

What I really want is the first 10 characters of the string NARR. It shouldn't require such a long expression. The compiler should be able to make sure I don't get that error. If the length of the string is less than the size parameter, just bring back what you can. In fact, if the starting position is beyond the end of the string, the result should be an empty string, not an error.

So for %subst(string: start: length): if start is beyond the length of string, should return an empty string. If start is not beyond length of string, but start + length is beyond the length of string, should return end of string beginning from start.


Use Case:

see description.


Idea priority Medium
  • Guest
    Reply
    |
    Apr 21, 2020

    IBM does not intend to provide a solution to this request at this time, so it is being closed.

    This request does not align with the strategy for future investment in the ILE RPG compiler. IBM feels that it would not enhance the maintainability of RPG programs if the "length" parameter for %SUBST could exceed the length of the string. Note that if the length operand is omitted from %SUBST, %SUBST returns the entire string starting at the start position.

  • Guest
    Reply
    |
    Jul 31, 2019

    And for that exact reason i wrote my own strLeft(), strRight(), strMid() library that is more lax to both offsets and lengths

    https://github.com/sitemule/ILEstdlib

    However I think it is a bug in %substr - but that of cause depends how you look at it.