IBM Support

RPG Cafe: Fall 2022: Concatenation built-in functions

News


Abstract

RPG enhancement delivered through PTFs in the fall of 2022. New built-in functions %CONCAT and %CONCATARR

Content

You are in: RPG Cafe > RPG Cafe: Fall 2022: Concatenation built-in functions

Short URL: https://ibm.biz/rpgcafe_fall_2022_concat

Fall 2022: Concatenation built-in functions

  • %CONCAT: Concatenate items with a separator
  • %CONCATARR: Concatenate array elements with separator

Details

%CONCAT

Built-in function %CONCAT concatenates operands 2 - N separated by the operand-1 separator.

If you don't want a separator, specify *NONE as the first operand.

If you want a single blank separator, you can specify *BLANK or *BLANKS as the first operand.

          string = %concat(', ' : 'Cow' : 'Moon' : 'Dish' : 'Spoon');
          // string = "Cow, Moon, Dish, Spoon"
          string = %concat(*none : 'Cow' : 'Moon' : 'Dish' : 'Spoon');
          // string = "CowMoonDishSpoon"

%CONCATARR

Built-in function %CONCATARR concatenates the elements of the operand-2 array separated by the operand-1 separator.

If you don't want a separator, specify *NONE as the first operand.

If you want a single blank separator, you can specify *BLANK or *BLANKS as the first operand.

          dcl-s array varchar(10) dim(4);
          array = %list('parsley' : 'sage' : 'rosemary' : 'thyme');
          string = %concatarr(':' : array);
          // string = "parsley:sage:rosemary:thyme"
          string = %concatarr(*blanks : %subarr(array : 1 : 3));
          // string = "parsley sage rosemary"

You can specify any array expression for %CONCATARR, including %SPLIT. In the following example, %SPLIT splits the string with several different separators, and %CONCATARR rejoins the resulting strings with a common separator.

          string = 'one. two, three; four';
          string = %concatarr(':' : %split(string : ',;. '));
          // string = "one:two:three:four"
.                                                            .
.                                                            .

PTFs for 7.4, and 7.5, available in December 2022

7.4:

  • ILE RPG compiler: 5770WDS SI81749

7.5:

  • ILE RPG compiler: 5770WDS SI81801
  • ILE RPG compiler, TGTRLS(V7R4M0): 5770WDS SI81819

The PTFs are also available with Db2 for i Fix Packs. See Db2 for IBM i 2022 PTF Group Schedule.

RDi support

A later update for RDi will support these enhancements.

Documentation

The 7.3, 7.4, and 7.5 ILE RPG Reference and ILE RPG Programmer's Guide are updated with full information about these enhancements. Start at the "What's new since 7.3", "What's new since 7.4", or "What's new since 7.5" section in the Reference.

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SS69QP","label":"Rational Development Studio for i"},"ARM Category":[{"code":"a8m0z0000000C4BAAU","label":"IBM i"},{"code":"a8m0z0000000CHtAAM","label":"Programming ILE Languages"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.4.0;and future releases"}]

Document Information

Modified date:
01 December 2022

UID

ibm16827009