%CHAR can convert the value of a numeric expression to type character.
If the value of the expression is float, the result will be in float format (for example '+1.125000000000000E+020'). Otherwise, the result will be in decimal format with a leading negative sign if the value is negative, and without leading zeros. The character used for any decimal point will be the character indicated by the control specification DECEDIT keyword (default is '.'). For example, %CHAR of a packed(7,3) expression might return the value '-1.234'.
The CCSID of the returned value is *JOBRUN.
%CHAR Examples with numeric parameters
D result S 100A VARYING D points S 10I 0 INZ(234) D total S 7P 2 INZ(523.45) D adjust S 7P 2 INZ(-123.45) D variance S 8F INZ(.01234)
result = 'You have ' + %char(points) + ' points.'; // result = 'You have 234 points.'
result = 'The variance is ' + %char(variance); // result = 'The variance is +1,234000000000000E-002'
result = 'Total is ' + %char(total) + ' and ' + 'Adjust is ' + %char(adjust); // result = 'Total is 523.45 and Adjust is -123.45'
result = 'Total is ' + %char(total) + ' and ' + 'Adjust is ' + %char(adjust); // result = 'Total is 523,45 and Adjust is -123,45'