Menu

Lesson 6 · Autumn 2026 RPG Enhancements

Initialize an RPG Array with INZ(*LIST)

Put the initial values beside an RPG array declaration. A small order-status example introduces INZ(*LIST), with downloadable source and expected output.

IBM iRPGArraysINZ(*LIST)Autumn 2026 RPG Enhancements

Three order statuses, three assignments. With INZ(*LIST), the initial values can live beside the array declaration, where the next developer will look for them.

Announcement preview

IBM lists this syntax for 7.6 TR3 and 7.5 TR9. As of October 28, 2026, the compiler PTF prerequisites have not been verified for this lesson. The source below is an example to validate on an updated IBM i; its output is expected, not captured from a run.

The small change

Suppose a sample program uses N, P, and S for new, processing, and shipped orders. One way to populate the array is:

dcl-s statuses char(1) dim(3);

statuses(1) = 'N';
statuses(2) = 'P';
statuses(3) = 'S';

The new declaration is:

dcl-s statuses char(1) dim(3)
  inz(*list : 'N' : 'P' : 'S');

IBM documents the form INZ(*LIST:value1:value2...) in its TR enhancement details. Here, the three values define the example’s initial status list. Keep the number of initializers equal to the explicit dimension for this first exercise.

The review question becomes easier: are these the three statuses this program should recognize? The answer is visible in one place.

Complete example

**free
ctl-opt dftactgrp(*no) actgrp(*new);

dcl-s statuses char(1) dim(3)
  inz(*list : 'N' : 'P' : 'S');
dcl-s idx int(10);
dcl-s message char(52);

for idx = 1 to %elem(statuses);
  message = 'Status ' + %trim(%char(idx))
          + ': ' + statuses(idx);
  dsply message;
endfor;

*inlr = *on;
return;

Expected message text, excluding the system’s display prefix and padding:

Status 1: N
Status 2: P
Status 3: S

Download INZLIST.rpgle and the compile and validation instructions.

Copy the source to the IFS path below, or adjust the command to the path you use. Run these CL commands in the same IBM i job, after confirming compiler support:

CRTBNDRPG PGM(QTEMP/INZLIST) SRCSTMF('/tmp/eraofi/INZLIST.rpgle') DBGVIEW(*SOURCE)
CALL PGM(QTEMP/INZLIST)

Try one change

Change the last initializer from 'S' to 'C', recompile, and call the program again. The final message should become Status 3: C. Save the compile listing and output so the example has a reproducible baseline on your partition.

Choose initialization deliberately

Use this example for a fixed list owned by the program. If business users need to add or remove valid statuses without a deployment, a database table may be a better home for the list.

Also review where existing assignments execute before replacing them with a declaration initializer. For example, assignments inside a repeatedly called routine may intentionally reload values on every call. This sample uses a fresh activation group and immediately displays the initialized array; it does not demonstrate that repeated-call scenario.

Prerequisites and the next lesson

Confirm the new feature’s compiler PTF for your release through RPG Cafe, including any target-release or runtime requirements IBM specifies. The July 2026 PTF list is not confirmation of support for this autumn addition. This example contains no embedded SQL; a SQLRPGLE adaptation needs its SQL precompiler support checked too.

The next improvement removes the manually maintained 3: Let RPG Count Your Array Elements with DIM(*INZ).

Back to the TR3/TR9 overview.

References

Documentation and references used for this lesson.

Comments

Share your thoughts, questions, or real-world IBM i experiences related to this article.