Notice the peculiar input specification in the RPG program RECCNT in the TechTalk technique "File Size Retriever". As of Release 2.0, you can now create named constants in this manner. What is a named constant? The result is similar to the FICA field in this example:
Z-ADD7.51 FICA 32
This statement assigns the value 7.51 to a field called FICA. The resulting difference between this field and a named constant is that you cannot change the assigned value of a named constant in the program. Other than that, you can use it just like any other field.
One of the biggest advantages of a named constant is that you can easily assign constant values larger than eight characters or ten digits (the limit of factor two in the calc spec). Without named constants, you would probably use the technique of defining the constant in a compile-time array and then moving that into the field. Now, you can define alphanumeric constants up to 256 characters and numeric constants up to 30 digits, right in the input specifications.
1 shows three examples of named constants. You can find all the coding rules in the RPG Reference Manual, pages 8-27 and 8-28, and the RPG User's Guide, page 9-26.
Figure 1 shows three examples of named constants. You can find all the coding rules in the RPG Reference Manual, pages 8-27 and 8-28, and the RPG User's Guide, page 9-26.
TechTalk: New: Named Constants in RPG
Figure 1 Examples of defining named constants
Figure 1: Examples of Defining Named Constants in RPG Input Specifications Here are some examples: 6..10....+...20....+...30....+...40....+...50....+...60....+...70 I* Single Line character constant I 'Y' C ACTIVE I* Continued character constant I 'Midrange - C TITLE I 'Computing' I* Continued numeric constant I 1234567- C NUMBER I 8.9999