ZONED( ) function

Converts a numeric value to ASCII zoned data format.

Syntax

ZONED(number, length)

Parameters

number

Numeric. The numeric expression or field value to convert.

length

Numeric constant. The length of the output string.

Output

Character.

Remarks

This function converts numeric data to character data and adds leading zeros to the output. The function is commonly used to harmonize fields that require leading zeros, for example, check number, purchase order number, and invoice number fields.

You can use the function to convert a positive numeric value to a character value containing leading zeros. This is useful for normalizing data in fields to be used as key fields. For example, if one table contains invoice numbers in the form 100 in a numeric field, and another table contains invoice numbers in the form 00100 in a character field, you can use ZONED( ) to convert the numeric value 100 to the character value 00100. This allows you to compare like invoice numbers.

Leading zeros are added to the output value when the length parameter is more than the number of digits in number. When length is less than the number of digits in number, the output is truncated from the left side. If the number parameter value is the same length as length, then no zeros are added.

The zoned data format does not include an explicit decimal point. Also, if the amount is negative, the rightmost digit is displayed as a character: “}” for zero, or as a letter between “J” and “R” for the digits 1 to 9.

If you are working with the Unicode edition of ACL, you need to use the BINTOSTR( ) function to correctly display the return value of the ZONED( ) function. You also need to use the BINTOSTR( ) function if you want to use the return value of the ZONED( ) function as a parameter in another function.

Examples

Example Return value

ZONED(235, 3)

“235”

ZONED(235, 5)

“00235”

Two leading zeros are added to the result because length is greater than the number of digits in number.

ZONED(235, 2)

“35”

The 2 is truncated from the result because length is less than the number of digits in number.

ZONED(235.85, 7)

“0023585”

The zoned data format does not specify a decimal point.

ZONED(-6448.94,11)

“0000064489M”

“M” represents the digit 4 and indicates that the number is negative

ZONED(-6448.91, 4)

“489J”

64 is truncated from the result because length is less than the number of digits in number.

Related reference
BINTOSTR( ) function


(C) 2013 ACL Services Ltd. All Rights Reserved. | Send feedback