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 Apr 16, 2018

RPG string templates

Modern applications are using strings more and more to provide data for documents and web applications.

Strings can be constructed today but the syntax get the process very convoluted especially when strings folds over several lines and contains variables.


Use Case:

Languages like ECMA6 ( Javascript) has introduced string templates with the following syntax – which can be adapted to RPG almost one-to-one.

Note the syntax uses back-single-quote:

name = 'John';
age = 25;
res = `My name is ${ name }. I am ${ age } years old`;

Giving the “res” equals to:

“My name is john. I am 25 years old ”;



The string can be constructed over several lines without any continuation characters.

The start of the template string is the accent grave character.

The expressions after the $ and between the curly bracket is normal RPG expressions except they need to be casted / converted with %char build in function.

The above example expands to:

res = ‘My name is ‘ + %char(name) ‘. I am ‘ + %char(age) + ‘ years old`;

Note: It requires that %char() of a string / string expression is not considered as an error but rather optimized away( which is an requirement to RPG by its self)

Maybe the $ and curly brackets could be discussed to be more RPG alike:

res = `My name is *( name ). I am *(age) years old`;


Also consider that template strings might be build in other CCSID's like Unicode or UTF-8, like in c:

#pragma charset(1208)

Not that this specific C-syntax has any appeal to a RPG programmer.


Idea priority Medium
  • Guest
    Reply
    |
    May 15, 2019

    i'd like to see this realized in RPG for the modern appeal.
    As an user of old net.data (booh!) i like the flexibility of this replacement feature.

  • Guest
    Reply
    |
    Jul 6, 2018

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

    However, there is a more general RFE requesting an "autostring" parameter option that would allow any type of parameter to be passed as a "readable" string to the procedure. if this other RFE were implemented, it would be relatively straightforward to write a procedure that would behave as described in the comment in this RFE from Peter Udeson. Here is a link to the "autostring" RFE: http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=112119. Those who are interested in this RFE may wish to vote for that other RFE.

  • Guest
    Reply
    |
    May 18, 2018

    The CEAC has reviewed this requirement and recommends that IBM view this as a high priority requirement that is important to be addressed.

    CEAC approved this requirement on July 17, 2017, previous reference AD0272.

    Background: The COMMON Europe Advisory Council (CEAC) members have a broad range of experience in working with small and medium-sized IBM i customers. CEAC 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 CEAC, see http://www.comeur.org/i4a/pages/index.cfm?pageid=3285

    Therese Eaton - CEAC Program Manager

  • Guest
    Reply
    |
    May 2, 2018

    Sounds like a good idea.
    It could be implemented like this:

    name = 'John';
    age = 25;

    res = %format( 'My name is $1. I am $2 years old. Today it is $3 or $4 in ISO format.'
    : name : age : %char( %date() : *EUR) : %date() );

    Giving the “res” equals to:
    “My name is john. I am 25 years old. Today it is 02.05.2018 or 2018-05-02 in ISO format”;

    The idea is that the parameters are transformed into its default text presentation or special formatted using %char().

  • Guest
    Reply
    |
    Apr 24, 2018

    One way to kind of accomplish this would be to use message's & substitution variables.

    For example ...

    Message id MSG0001 is 'My name is &1. I am &2 years old'.

    name = 'John';
    age = 25;

    Use QMHRTVM to retrieve MSG0001, passing in NAME & AGE as message data.

    Not perfect, but it does work.
    res = `My name is ${ name }. I am ${ age } years old`;