The HEX function returns a character-string value that is the
hexadecimal equivalent of the specified parameter. The return
value is compatible with all other string types.
Syntax:
HEX( x [[, length[[, digits]]]] )
The parameter 'x' is the expression to be converted. This
parameter must have a size that is known at compile time; it
cannot be VARYING OF CHAR, a conformant parameter, or a schema
type.
Two optional integer parameters specify the length of the
resulting string and the minimum number of significant digits to
be returned. If you specify a length that is too short to hold
the converted value, the resulting string is truncated on the
left. If you do not specify values for the optional parameters,
a default length and a default number of significant digits is
used.
By default, the number of significant digits is the minimum
number of characters necessary to express all the bits of the
converted parameter. This default length is one character more
than the default number of digits, which causes a leading blank
to be included in the resulting string when both parameters are
omitted.