The picture characters S, +, and - specify signs in numeric character data. The picture character $ (or the currency symbol) specifies a currency symbol in the character value of numeric character data. Only one type of sign character can appear in each field.
In the following example:
dcl Price picture '$99V.99'; Price = 12.45;
The character value of Price is '$12.45'. Its arithmetic value is 12.45.
For information on specifying a character as a currency symbol, refer to Defining currency symbols.
Consider the following example:
dcl Root picture 'S999';
The value 50 is held as '+050', the value 0 as '+000' and the value -243 as '-243'.
Signs and currency symbols can be used in either a static or a drifting manner.
Static use specifies that a sign, a currency symbol, or a blank appears in the associated position. An S, +, or - used as a static character can appear to the right or left of all digits in the mantissa and exponent fields of a floating-point specification, and to the right or left of all digit positions of a fixed-point specification.
Drifting use specifies that leading zeros are to be suppressed. In this case, the rightmost suppressed position associated with the picture character will contain a sign, a blank, or a currency symbol (except that where all digit positions are occupied by drifting characters and the value of the data item is zero, the drifting character is not inserted).
A drifting character is specified by multiple use of that character in a picture field. The drifting character must be specified in each digit position through which it can drift. Drifting characters must appear in a sequence of the same drifting character, optionally containing a V and one of the insertion characters comma, point, slash, or B. Any of the insertion characters slash, comma, or point within or immediately following the string is part of the drifting string. The character B always causes insertion of a blank, wherever it appears. A V terminates the drifting string, except when the arithmetic value of the data item is zero; in that case, the V is ignored. A field of a picture specification can contain only one drifting string. A drifting string cannot be preceded by a digit position nor can it occur in the same field as the picture characters * and Z.
The position in the data associated with the characters slash, comma, and point appearing in a string of drifting characters contains one of the following:
If a drifting string contains the drifting character n times, the string is associated with n-1 conditional digit positions. The position associated with the leftmost drifting character can contain only the drifting character or blank, never a digit. Two different picture characters cannot be used in a drifting manner in the same field.
If a drifting string contains a V within it, the V delimits the preceding portion as a subfield, and all digit positions of the subfield following the V must also be part of the drifting string that commences the second subfield.
In the case in which all digit positions after the V contain drifting characters, suppression in the subfield occurs only if all of the integer and fractional digits are zero. The resulting edited data item is then all blanks (except for any insertion characters at the start of the field). If there are any nonzero fractional digits, the entire fractional portion appears unsuppressed.
If, during or before assignment to a picture, the fractional digits of a decimal number are truncated so that the resulting value is zero, the sign inserted in the picture corresponds to the value of the decimal number prior to its truncation. Thus, the sign in the picture depends on how the decimal value was calculated.
Table 39 shows examples of signs and currency symbol characters.
|
Source Attributes |
Source Data (in constant form) |
Picture Specification |
Character Value |
|---|---|---|---|
|
FIXED(5,2) FIXED(5,2) FIXED(5,2) |
123.45 012.00 001.23 |
$999V.99 99$ $ZZZV.99 |
$123.45 12$ $bb1.23 |
|
FIXED(5,2) FIXED(1) FIXED(5,2) |
000.00 0 123.45 |
$ZZZV.ZZ $$$.$$ $$$9V.99 |
bbbbbbb bbbbbb $123.45 |
|
FIXED(5,2) FIXED(2) FIXED(4) |
001.23 12 1234 |
$$$9V.99 $$$,999 $$$,999 |
bb$1.23 bbb$012 b$1,234 |
|
FIXED(5,2) FIXED(5) FIXED(5) |
2.45 214 -4 |
SZZZV.99 SS,SS9 SS,SS9 |
+bb2.45 bb+214 bbbb-4 |
|
FIXED(5,2) FIXED(5,2) FIXED(5,2) |
-123.45 -123.45 123.45 |
+999V.99 -999V.99 999V.99S |
b123.45 -123.45 123.45+ |
|
FIXED(5,2) FIXED(5,2) FIXED(5,2) |
001.23 001.23 -001.23 |
++B+9V.99 - - -9V.99 SSS9V.99 |
bbb+1.23 bbb1.23 bb-1.23 |