Converting Number to Character and vise versa 
Written by Chamara Withanachchi  
Use %EDITC built in function to conver to Character %EDITC(numeric : editcode {: *ASTFILL  *CURSYM  currencysymbol}) This function returns a character result representing the numeric value edited according to the edit code. In general, the rules for the numeric value and edit code are identical to those for editing numeric values in output specifications. The third parameter is optional, and if specified, must be one of:
The result of %EDITC is always the same length, and may contain leading and trailing blanks. For example, %EDITC(NUM : 'A' : '$') might return '$1,234.56CR' for one value of NUM and ' $4.56 ' for another value.
Float expressions are not allowed in the first parameter (you can use %DEC to convert a float to an editable format). In the second parameter, the edit code is specified as a character constant; supported edit codes are: 'A'  'D', 'J'  'Q', 'X'  'Z', '1'  '9'. The constant can be a literal, named constant or an expression whose value can be determined at compile time.
Use %DEC to conver to Decimal Format
%DEC(numeric expression{:precision:decimal places}) %DEC converts the value of the numeric expression to decimal (packed) format with precision digits and decimal places decimal positions. The precision and decimal places must be numeric literals, named constants that represent numeric literals, or builtin functions with a numeric value known at compiletime.
Parameters precision and decimal places may be omitted if the type of numeric expression is not float. If these parameters are omitted, the precision and decimal places are taken from the attributes of numeric expression.
Use %INT to convert to Integer format
%INT(numeric expression) %INT converts the value of the numeric expression to integer. Any decimal digits are truncated. This builtin function may only be used in expressions. %INT can be used to truncate the decimal positions from a float or decimal value allowing it to be used as an array index.

<Previous  Next> 
