Rules for Using Numeric Picture Data

The rules for using numeric picture data are as follows:

  1. A numeric picture cannot contain more than one sign character ('+', '–', 'S', 'T', 'I', 'R', 'CR', or 'DB') unless all such sign characters are part of a drifting string.
  2. When a zero value is assigned to a numeric pictured variable and the numeric picture does not contain at least one '9', the entire value is filled with blanks or with asterisks (*), depending on which zero-suppression character was used.
  3. When a nonzero value is assigned to a numeric pictured variable, and the 'V' is followed by zero-suppression characters or by part of a drifting string, the 'V' stops zero suppression. For example:
    DECLARE A PICTURE 'ZZZV.ZZ'; 
    DECLARE B PICTURE '***V.**CR';

    In this example, a value of . 01 assigned to A and B produces boxes and .boxes. A value of zero assigned to A and B produces boxes and ********.

  4. If a 'V' is not given, a 'V' is implied at the rightmost end of the numeric picture.
  5. Each '9', 'Z', or '*' is considered to be a digit of precision. Within a drifting string each 'S', '+', '–', or '$', except the first one, is considered to be a digit of precision. All digits of precision following the 'V' are fractional digits. For example:
    DECLARE A PICTURE 'ZZZV.ZZ' 
    DECLARE B PICTURE '---V.z--'

    In this example, A has a precision of (5,2), while B has a precision of (4,2).

  6. Negative values cannot be assigned to a numeric pictured variable unless the picture contains a 'CR', 'DB', '–', or 'S'. An error condition is signaled if a negative value is assigned to a numeric pictured variable that does not contain 'S', '+', '–', 'T', 'I', 'R', 'CR', or 'DB'.
  7. Values assigned to numeric pictured variables are truncated and aligned with the `V' as they would be when assigned to a fixed decimal variable of the equivalent precision.
  8. Used in contexts that expect an arithmetic value, or used with a relational operator, numeric pictured values are converted to fixed-point decimal values with a precision p and q that are determined by the numeric picture.
  9. A numeric pictured value is operated upon as if it were a character-string value only when it is assigned to a character-string variable, and when it is an operand of the concatenate operator or of a built-in function that expects character-string operands. In all other contexts, numeric pictured values are operated upon as if they were fixed-point decimal values.

Following are more examples of picture format output.

Example     Data Picture Output
1 12345.60 $SSSSSSSSV.99 $ boxes   +12345.60
2 1.23 **********V.99 .********1.23
3 1.23 ZZZZZZZZZZV.99S boxes1.23
4 1234.56 Z.ZZZ ZZZV,99 boxes1.234,56
5 11011111 9999B9999 1101  boxes1111
6 011335 **/**/** *1/13/35
7 1234567890     999999999V.99 234567890.00
8 .33 ZV.ZZ box.33
9 .75 ZV.ZZ box.75
10 1234567.89 $999,999,999V.99DB     $001,234,567.89
11 -1234567.89 $999,999,999V.99CR $001,234,567.89CR
12 1023 YYYYY 1  23

In example 1, '$' is a static character because it appears only once, whereas 'S' is a drifting character because it appears all the way to the decimal.

In examples 2, 3, and 4, the characters 'Z' and '*' are zero-suppression characters. The asterisk prints wherever a zero or blank would have printed, and the 'Z' substitutes blanks.

In example 5 the insertion character 'B' results in a space (blank). A blank is inserted wherever the 'B' appears in the numeric picture format unless it is in a field of zero-suppression characters that are suppressing zeros at the time.

In example 7, the appearance of the character '9' results in the printing of a digit. All digits 0 through 9 are printed, except the leading one, which is truncated.

In examples 8 and 9, the character 'V', once encountered, turns off suppression; all characters after the 'V' are printed. Note that in Example 8, 'V' is not used before the decimal point, so the point is turned off, not on.

Examples 10 and 11 show the result of positive and negative data applied to numeric pictures that contain either 'CR' or 'DB'.