FTOA: Converting a Number to Alphanumeric Format

How to:

Available Languages: reporting, Maintain

The FTOA function converts a number up to 16 digits long from numeric format to alphanumeric format. It retains the decimal positions of the number and right-justifies it with leading spaces. You can also add edit options to a number converted by FTOA.

When using FTOA to convert a number containing decimals to a character string, you must specify an alphanumeric format large enough to accommodate both the integer and decimal portions of the number. For example, a D12.2 format is converted to A14. If the output format is not large enough, decimals are truncated.

Syntax: How to Convert a Number to Alphanumeric Format

FTOA(number, '(format)', output)

where:

number

Numeric F or D (single and double precision floating-point)

Is the number to be converted, or the name of the field that contains the number.

format

Alphanumeric

Is the format of the number to be converted enclosed in parentheses. Only floating point single-precision and double-precision formats are supported. Include any edit options that you want to appear in the output. The D (floating-point double-precision) format automatically supplies commas.

If you use a field name for this argument, specify the name without quotation marks or parentheses. If you specify a format, the format must be enclosed in single quotation marks and parentheses.

output

Alphanumeric

Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks. The length of this argument must be greater than the length of number and must account for edit options and a possible negative sign.

Example: Converting From Numeric to Alphanumeric Format

FTOA converts the GROSS field from floating point double-precision to alphanumeric format and stores the result in ALPHA_GROSS:

TABLE FILE EMPLOYEE
PRINT GROSS AND COMPUTE
ALPHA_GROSS/A15 = FTOA(GROSS, '(D12.2)', ALPHA_GROSS);
BY HIGHEST 1 PAY_DATE NOPRINT
BY LAST_NAME
WHERE (GROSS GT 800) AND (GROSS LT 2300);
END

The output is:

LAST_NAME  GROSS       ALPHA_GROSS 
---------  -----       ----------- 
BLACKWOOD  $1,815.00      1,815.00 
CROSS      $2,255.00      2,255.00 
IRVING     $2,238.50      2,238.50 
JONES      $1,540.00      1,540.00 
MCKNIGHT   $1,342.00      1,342.00 
ROMANS     $1,760.00      1,760.00 
SMITH      $1,100.00      1,100.00 
STEVENS      $916.67        916.67