Previous Topic: RPG III Parameter and Key Lists

Next Topic: Techniques in RPG III Programs

RPG III Standard Indicators

The RPG III indicators (such as, 01-99) should be used as little as possible, as they are difficult to reconcile with structured programming. The number of indicators available is in any case fixed, so it is best to reserve their use for the places where you are obliged to use them. Ideally, indicators should only be used to:

Note: Avoid using numeric indicators to condition code execution. Where branching is conditional on a test, it is clearer to repeat the test, rather than use an intermediate indicator.

Where you need to use a logical indicator, for example, because a test is too complicated to repeat easily, it is often better to define your own variable and give it a meaningful name, rather than use one of the RPG III numeric indicators.

Try to give the same meaning to indicator usage throughout a system. This makes it easier to understand programs. Use specific indicators for functions that are common to many programs, such as command keys, and use a different range of indicators for functions that are specific to a particular program, or part of a program. Indicator usage should follow the following convention:

Note: The usage of certain indicators has been revised since the previous edition of these standards. The old values are shown in brackets.

Using standard indicators in device files should be documented in the device files using the DDS INDTXT, SETOF, CAnn or CFnn keywords; it should not need to be repeated in the RPG III program source.

Document the use of non-volatile indicators (for example, those which have a global scope rather than a local use). For example, ‘*IN87 = Company is insolvent’.

Where an indicator is returned/required by a subroutine, document its meaning at the beginning of the subroutine.