In the basic string, you use digit placeholders, message characters, and the decimal point placeholder to control how a given value appears. The basic string begins with the first placeholder and ends with the last placeholder.
|
|
|
|
|
$PIC(12, '999') returns 012
$PIC(1234, '$999,999') returns $001,234
|
|
Displays leading zeros as asterisks (*).
|
$PIC(12, '***') returns *12
$PIC(1234, '$***,***') returns $**1,234
|
|
Displays leading zeros as blanks.
|
$PIC(12, 'ZZZ') returns 12
$PIC(1234, '$ZZZ,ZZZ') returns $ 1,234
|
|
Displays leading zeros as nulls
|
$PIC(12, 'NNN') returns 12
$PIC(1234, '$NNN,NNN') returns $1,234
|
A display mask can optionally contain message characters that do not serve as placeholders and are output as ordinary characters. Characters other than the digit placeholders are always treated as message characters, with the following exceptions:
|
|
They precede the first dollar sign ($) in a mask.
|
In the mask ‘NZ$AZZ9’, the initial ‘NZ’ is an ordinary character string, and the ‘ZZ9’ after the $ are digit placeholders.
$PIC(123, ' NZ$AZZ9' ) returns NZ$A123
|
An asterisk (*), Z, or N follows a different digit placeholder.
Note 9 is always a digit placeholder even if it appears after another digit placeholder, so an asterisk (*), Z, or N following it is treated as a message character.
|
In the mask ‘ABCZZNZ’, all three Zs are placeholders, and the N is treated as an ordinary character.
$PIC(123, ' ABCZZNZ' ) returns ABC12N3
Note Any characters after the last digit placeholder up to either the end of the string or a percent sign are conditional, and their appearance depends on the value of the sign holder in the unconditional left string. Therefore:
$PIC(123, ' ABCZZ9Z' ) returns ABC123, not ABC123Z.
|
|
In the mask ‘Z99%9’, the second 9 is the last digit placeholder, and the last 9 is an ordinary character.
$PIC(123, ' Z99%9' ) returns 123%9
|
For more information on how the dollar sign ($) and the percent sign (%) characters are used in other elements in the mask, refer to the sections on the unconditional left and right strings below.
Use the unconditional left string to prepend message characters to the basic string. The unconditional left string consists of all characters that precede the first placeholder, and has two parts, both of which are optional: a character string and a sign holder.
To include in the unconditional left string any characters that ordinarily serve as placeholders or have special functions, place them before the first placeholders in the mask. As well, any characters preceding the first dollar sign in a mask are treated as message characters, except for the percent sign (%) character, which cannot be used in the unconditional left string. Subsequent dollar signs ($) in a mask are treated as message characters. For example:
Using the sign holder, you can display whether value is positive or negative. The first positive (+) or negative (-) sign before the first placeholder is the sign holder. Subsequent positive or negative signs are treated as message characters. The sign holder follows these rules:
Use a conditional right string to append a set of message characters to the basic string that appear only when
value is negative. For example, this element can be used to append the characters CR when a credit is due. The conditional right string consists of all characters after the last digit placeholder, unless a percent sign (%) marks the start of an unconditional right string. If a percent (%) sign is present, the conditional right string consists of all characters between the last digit placeholder and the percent sign, which signals the beginning of the unconditional right string (refer to
Unconditional Right String below). The conditional right string follows these rules:
Use the unconditional right string to append characters to the basic string or conditional right string that always appear regardless of whether
value is positive or negative. The unconditional right string begins with a percent sign (%) character. Characters that follow a percent sign (%) character appear as message characters, including all placeholders and characters with special functions.
The $UNPIC tool, which, given a masked value produced by $PIC and the display mask that produced it, determines the original value submitted.
The following rule formats an input amount so that it appears with commas, a decimal marker, and a negative sign if necessary, and then displays the formatted amount in the end message.