SPELLNM: Spelling Out a Dollar Amount

How to:

Available Languages: reporting, Maintain

The SPELLNM function spells out an alphanumeric string or numeric value containing two decimal places as dollars and cents. For example, the value 32.50 is THIRTY TWO DOLLARS AND FIFTY CENTS.

Syntax: How to Spell Out a Dollar Amount

SPELLNM(outlength, number, output)

where:

outlength

Integer

Is the number of characters in output , or a field that contains the length.

If you know the maximum value of number, use the following table to determine the value of outlength:

If number is less than...

...outlength should be

$10

37

$100

45

$1,000

59

$10,000

74

$100,000

82

$1,000,000

96

number

Alphanumeric or Numeric (9.2)

Is the number to be spelled out. This value must contain two decimal places.

output

Alphanumeric

Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.

Example: Spelling Out a Dollar Amount

SPELLNM spells out the values in CURR_SAL and stores the result in AMT_IN_WORDS:

TABLE FILE EMPLOYEE
PRINT CURR_SAL AND COMPUTE
AMT_IN_WORDS/A82 = SPELLNM(82, CURR_SAL, AMT_IN_WORDS);
WHERE DEPARTMENT EQ 'MIS'
END

The output is:

CURR_SAL    AMT_IN_WORDS
--------    ------------
$13,200.00  THIRTEEN THOUSAND TWO HUNDRED DOLLARS AND NO CENTS
$18,480.00  EIGHTEEN THOUSAND FOUR HUNDRED EIGHTY DOLLARS AND NO CENTS
$18,480.00  EIGHTEEN THOUSAND FOUR HUNDRED EIGHTY DOLLARS AND NO CENTS
$21,780.00  TWENTY-ONE THOUSAND SEVEN HUNDRED EIGHTY DOLLARS AND NO CENTS
$9,000.00   NINE THOUSAND DOLLARS AND NO CENTS
$27,062.00  TWENTY-SEVEN THOUSAND SIXTY-TWO DOLLARS AND NO CENTS