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).
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:
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 an idea.
Get feedback from the IBM team and other customers to refine your idea.
Follow the idea through the IBM Ideas process.
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.
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
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.
That's an elegant way of using DATA-GEN.
Thanks for sharing
Here is a support document with the same content that I posted in the blog article.
https://www.ibm.com/support/pages/node/6508862
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.
@Barbara Morris: I get the message "You do not have permission to view this blog post" when trying to see what you have written.
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
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.
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.
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);
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.