Coding Standards for Database Files › Coding Standards for RPG III Programs › RPG III Field Names
RPG III Field Names
Program field names should follow the rules laid out in the naming convention.
The names of fields should, wherever possible, be the same as those in the file from which they are obtained. This helps to standardize the naming of fields, and also makes clearer the mapping of fields between files. If necessary, a different prefix can be used to indicate that the field is a work field or a device field: for example, JJCUCD could give P1CUCD, #1CUCD, and WWCUCD.

Note: Format identifier: ‘II’ is either the format identifier from a database or a device file or work prefix.

Note: Mnemonic: MMMM is a mnemonic constructed according to the rules given in the chapter on naming conventions.

For the names of fields which act as accumulators, use an appropriate prefix + the mnemonic of the field being accumulated. This helps to make mapping a field from format to format, clear.
There are some exceptions to the above rules:
- Arrays—The names of arrays should begin with the character ‘@’, and otherwise consists of one, two or three letters, for example @X, @LN, @PRC. This leaves space for an index.
- Array indices—The names of array indices should, if possible, relate to the names of the arrays they index. For example, they should contain the same letters and be prefixed by a ‘$’ instead of an ‘@’. They should also be short, since indexed occurrences of arrays must fit into RPG III calculation specification fields. For example, $X might be the name of the index for array @X, giving @X,$X as an occurrence, $LN for array @LN, giving @LN,$LN.
- Standard fields—Fields that serve the same common role in many different programs may use a single three-character mnemonic to indicate that they are standard fields; for instance, xxRTN - the return code.CA 2E uses this technique.
- Parameter fields—Fields that are parameters passed to other types of programs may, in order to keep the field names the same in both programs, take the field name as it appears in the other program. For instance, in the following example, ‘MSGID’ and ‘MSGDTA’ is a field name that does not conform to the normal RPG naming convention. However, it is the name used in the CL message-sending program that is being called.