PTOA: Converting a Number to Alphanumeric Format

How to:

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

PTOA is similar to FTOA, however PTOA converts numbers with 17 format to 31 digits.

When using PTOA 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 P18.2 format is converted to A20. If the output format is not large enough, decimals are truncated.


Top of page

x
Syntax: How to Convert a Number to Alphanumeric Format
PTOA(number, '(format)', output_format)

where:

number

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

Is the number to be converted.

format

Alphanumeric

Is the format of the number to be converted enclosed in parentheses.

Parentheses are required around the format.

output_format

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 the number and must account for edit options and a possible negative sign.



Example: Converting From Packed to Alphanumeric Format

PTOA converts PGROSS from packed-decimal to alphanumeric format.

PTOA(PGROSS, FMT, 'A17')

iWay Software