IBM Support

RPG Cafe: Spring 2023: %SPLIT to handle all separators

News


Abstract

RPG enhancement delivered through PTFs in the spring of 2023. %SPLIT to handle all separators

Content

You are in: RPG Cafe > RPG Cafe: Spring 2023: %SPLIT to handle all separators

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

Warning

If you use %SPLIT with *ALLSEP in your program, you need a runtime PTF on any system where you run the program. If the runtime PTF is not applied on the system where the program is running, the call to the program fails with MCH4437 saying that a program export is not found.

Spring 2023: %SPLIT to handle all separators

When *ALLSEP is specified for %SPLIT, every separator is considered to separate two substrings. If the string begins or ends with a separator, or one separator immediately follows another, an empty string substring is returned for that separator.

Example

          dcl-s string varchar(200);
          dcl-s s varchar(20);

          string = ',,television,5,,1 Elm Street,,';\

          // With *ALLSEP
          for-each s in %split(string : ','  : *allsep );
             dsply s;
             // values for s in the for-each loop:
             //    1  (empty string)
             //    2  (empty string)
             //    3  "television"
             //    4  "5"
             //    5  (empty string)
             //    6  "1 Elm Street"
             //    7  (empty string)
             //    8  (empty string)
          endfor;

          // Without *ALLSEP
          for-each s in %split(string : ',');
             dsply s;
             // values for s in the for-each loop:
             //    1  "television"
             //    2  "5"
             //    3  "1 Elm Street"
          endfor;
.                                                            .
.                                                            .

PTFs for 7.4, and 7.5

7.4:

  • ILE RPG compiler: 5770WDS SI83497
  • ILE RPG runtime: 5770SS1 SI83471

7.5:

  • ILE RPG compiler: 5770WDS SI83480
  • ILE RPG compiler, TGTRLS(V7R4M0): 5770WDS SI83496
  • ILE RPG runtime: 5770SS1 SI83468

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

RDi support

A later update for RDi will support these enhancements.

Documentation

The 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.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"}],"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.4.0;7.5.0;and future releases"}]

Document Information

Modified date:
11 May 2023

UID

ibm16982241