How does the CONST keyword work with Procedure parameters?
If you are certain that the called procedure will NOT modify a parameter, the CONST keyword can provide several benefits. • It automatically converts a field of a similar data type, to the length and type required by the parameter. What this means, is say a parameter is a 15 position pack field, with 5 decimals. Normally, you’d have to specify a Pdk(15,5) field for the parameter. However, if the parameter is read-only, you can specify CONST on the Prototype and Procedure Interface for the parameter. When you do this, the compiler automatically converts the value (say it’s a literal of 27) to the size and type required by the parameter. This works really cool with DATE fields. A date for any format can be passed as a parameter value when that parameter value is CONST. • Performance is improved because the compiler can generate more optimized code for the CONST parameter. CONST can be used on calls to procedures or programs. We use it all the time when calling QCMDEXC from within RPG IV.