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 Oct 20, 2021

String interpolation for RPG

Add string interpolation support so variables can be inserted into string literals without having to use concatenation with + symbols and multiple literals.

For example:
apples = 4
bananas = 3
print(f"I have {apples} apples and {bananas} bananas")


Use Case:

This would be a boon to programmers, increasing speed and reducing errors. Combining literals and variables is an extremely common task.


Idea priority Medium
  • Guest
    Reply
    |
    Dec 6, 2022

    The compiler could and should support this. It should even implicitly convert to string because that's the only time someone would be using string interpolation (they want a string). If the format isn't what is wanted from the job defaults (say MDY instead of ISO dates) then that'd be up to the programmer to convert.


    Other languages seem to have no issue doing this.

    Python https://peps.python.org/pep-0498/

    Javascript https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

  • Guest
    Reply
    |
    Nov 18, 2021

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

    While we agree with the request, we do not plan to implement it at this time. Here are two of the reasons that the RFE is being closed at this time:

    - This kind of string interpolation would be limited to literals, since RPG would need to know at compile-time what field values were needed.

    - The suggestion made in the comments to use DATA-GEN might prove useful, even though the syntax is not as convenient, and even though it requires all the required fields to be coded in a single data structure.

  • Guest
    Reply
    |
    Oct 27, 2021

    That's an elegant way of using DATA-GEN.
    Thanks for sharing

  • Guest
    Reply
    |
    Oct 26, 2021

    Here is a support document with the same content that I posted in the blog article.
    https://www.ibm.com/support/pages/node/6508862

  • Guest
    Reply
    |
    Oct 26, 2021

    Sorry about that Peder. I didn't realize it was restricted. Perhaps it's restricted to members of the RPG community. I will add a similar document to Support and post the link here.

  • Guest
    Reply
    |
    Oct 26, 2021

    @Barbara Morris: I get the message "You do not have permission to view this blog post" when trying to see what you have written.

  • Guest
    Reply
    |
    Oct 25, 2021

    I wrote a blog about how you can use DATA-GEN for this:
    https://community.ibm.com/community/user/power/blogs/barbara-morris/2021/10/25/use-data-gen-for-string-interpolation

  • Guest
    Reply
    |
    Oct 21, 2021

    This is a duplicate of:

    http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=118923

    The original RFE had more details and are more precise, however was declined. This current RFE will reopen the case.

  • Guest
    Reply
    |
    Oct 21, 2021

    While there have been a number of significant enhancements dealing with string functions over the years, we're still missing the capstone feature of a simple (a.k.a. intuitive) and efficient "string interpolation" technique. I've done my share of "bare metal" string coding with lookup's and MOVEA's; modern string management opcodes have greatly simplified my developed and enabled better applications.

    I'd use such a feature when building dynamic SQL, error messages, printed forms (letters), and display file output/input. It would greatly simplify my code generation utilities as well.

    Some RFE's are relatively narrow in their focus and application. If implemented, this candidate will be widely accepted and used.

  • Guest
    Reply
    |
    Oct 21, 2021

    You can use the C-functions like sprintf (and wrap it in an easy to use procedure) in RPG to get similar results.

    Another option is...

    apples = 4;
    bananas = 3;
    s = "I have {apples} apples and {bananas} bananas";
    s = %ScanRpl('{apples}': %Char(apples): s);
    s = %ScanRpl('{bananas}': %Char(bananas): s);

  • Guest
    Reply
    |
    Oct 20, 2021

    I think that it would be useful to have it accept function calls, BIFs, etc. as well as simple variable names as the replacement values. That way you could format numerics any way you want without having to create temporary character variables.