IBM Support

RPG Cafe: %KDS allows a variable number of keys



RPG enhancement for the %KDS built-in function with PTFs for 7.3 and 7.4.


You are in: RPG Cafe > Spring 2020: %KDS allows a variable number of keys

Short URL:

RPG Cafe: %KDS(ds : var_num_keys)

You can now specify a variable for the second parameter of %KDS.

PTFs for 7.3 and 7.4, available in May 2020.


  • ILE RPG compiler: SI73190
  • ILE RPG runtime: SI73189


  • ILE RPG compiler: SI73192
  • ILE RPG runtime: SI73191>
  • ILE RPG compiler, TGTRLS(V7R3M0): SI73193

The PTFs are also available with the Db2 for i Fix Packs of 15 May 2020. See Db2 for IBM i 2020 PTF Group Schedule.


Variable number of keys for %KDS

Formerly, if you wanted to limit the number of keys used by %KDS, you had to specify a constant.

          DCL-DS keys EXTNAME('MYFILE' : *KEY) END-DS;
          DCL-S num_keys INT(10);

          WHEN num_keys = 1;
             CHAIN %KDS(keys : 1) MYFILE;
          WHEN num_keys = 2;
             CHAIN %KDS(keys : 2) MYFILE;

Now, you can specify a variable.

          DCL-DS keys EXTNAME('MYFILE' : *KEY) END-DS;
          DCL-S num_keys INT(10);

          CHAIN %KDS(keys : num_keys) MYFILE;

RDi support

The next release of RDi will support this enhancement.

Documentation in the IBM Knowledge Center

The ILE RPG Reference and ILE RPG Programmer's Guide in the 7.3 and 7.4 IBM Knowledge Center are updated with full information about this enhancement. Start at the What's New Since 7.3 or What's New Since 7.4 section in the Reference.

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SS69QP","label":"Rational Development Studio for i"},"Component":"ILE RPG Compiler","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.3;7.4","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
15 May 2020