Numeric or character expression
When the first parameter is a numeric or character expression,
the result has precision digits and decimal places decimal positions. The precision
and decimal places must be numeric literals, named constants that
represent numeric literals, or built-in functions with a numeric value
known at compile-time.
Note: %LEN and %DECPOS cannot be
used directly for the second and third parameters of %DEC or %DECH,
even if the values of %LEN and %DECPOS are constant. See Figure 1 for an example using the length and decimal positions
of a variable to control %DEC and %DECH.
Parameters precision and decimal places may be omitted if the type of expression is neither float nor character. If these parameters are omitted, the precision and decimal places are taken from the attributes of the numeric expression.
If the parameter is a character expression
- See Rules for converting character values to numeric values using built-in functions for the rules for character expressions for %DEC.
- Floating point data, for example '1.2E6', is not allowed.
- If invalid numeric data is found, an exception occurs with status code 105.
See %DECH for examples using %DEC.