PICTURE Clause

The PICTURE clause describes the general characteristics and editing formats of an elementary item.

General Format

{PICTURE} IS picture-string
{PIC    }

Syntax Rules

  1. A PICTURE clause can appear for elementary items only.
  2. The maximum size of the picture-string is 100 characters.
  3. A PICTURE clause is required for every elementary data item except for those items with a USAGE clause that disallows a PICTURE, or those items that are the subject of a RENAMES clause. A PICTURE clause is prohibited for these items.
  4. PIC and PICTURE may be used interchangeably.
  5. A picture is invalid if it specifies more than 31 digits to the left of the decimal point or more than 32 digits to the right of the decimal point, including assumed zero digits represented by"P and floating insertion positions that may hold digits. If a picture exceeds these scaling limitations, a compile-time error message is produced.

General Rules

The PICTURE clause defines a data item as belonging to one of five categories and determines what the item can contain. The five categories are:

  • Alphabetic
  • Numeric
  • Alphanumeric
  • Alphanumeric Edited
  • Numeric Edited
  1. An item is alphabetic when its picture-string consists solely of A symbols.
  2. An alphabetic item may contain only one or more alphabetic characters.
Note: The alphabetic declaration shows the programmer's intent to store only alphabetic data, however the system does not provide any checks to ensure compliance.
  1. An item is numeric when its picture-string contains only the symbols 9, P, S, and V. The number of digit positions described by picture-string must range from 1 to 18 inclusive. This increases to 31 digit positions if 31-digit support (-Dd31 compiler option) is in effect.
  2. If unsigned, its contents must be one or more numeric characters. If signed, then the item may also contain a "+" or "-" (or other representation of the sign). See SIGN Clause for more information.
  3. The numeric category of the PICTURE clause includes an external floating-point data item, which is defined by a picture that strongly resembles a floating-point numeric literal.
  1. An item is alphanumeric when its picture-string consists solely of the symbols A, X, and 9. A picture-string containing all A or all 9 symbols is not alphanumeric. When used in an alphanumeric item, the A and 9 symbols are treated as if they were X symbols.
  2. Its contents may contain one or more characters in the computer's character set.
  1. An item is alphanumeric edited when its picture-string contains certain combinations of the symbols A, X, 9, B, 0, and /. The picture-string must contain at least one A or X symbol and at least one B, 0, or / symbol.
  2. Its contents may contain two or more characters in the computer's character set.
  1. An item is numeric edited when its picture-string contains certain combinations of the symbols B, /, P, V, Z, 0, 9, comma, period, *, +, -, CR, DB, and the currency symbol. The number of digit positions that can be represented by the picture-string must range between 1 and 18 inclusive. This increases to 31 digit positions if 31-digit support (-Dd31) is in effect. The picture-string must contain at least one 0, B, /, Z, *, +, comma, period, -, CR, DB, or currency symbol.
  2. The content of each character position must be consistent with the corresponding PICTURE symbol.
  1. Some PICTURE symbols represent character positions and some do not. A data item's size is determined by adding up all the symbols that represent character positions.
  2. A picture-string may contain repeat counts for its symbols. You denote this by placing the repeat count in parentheses immediately after the symbol that is being repeated. For example, X(4) and XXXX are equivalent PICTURE strings.
  3. Only one S may appear in a PICTURE string, and it must be the leftmost character. Only one of the following symbols may appear in a PICTURE string: V or the period character. It may appear only once. At least one of the symbols A, X, Z, 9, or * or at least two occurrences of the symbols +, -, or the currency symbol must be present in a PICTURE string.

The PICTURE symbols and their functions are the following:

A Represents a character position that can contain only an alphabetic character. It is counted in the size of an item. An alphabetic character is any character A through Z, "a" through z, or a space.
B Represents a character position where a space will be inserted. It is counted in the size of an item.
E A delimiter directly preceding the (signed or unsigned) exponent part of an External Floating-Point notation. The exponent is always exactly two digits long, so the last two characters of the picture must be 99. This delimiter is counted in the size of an item.
P This symbol is used to specify an assumed scaling position in a number. The P character is not counted in the size of the data item. Instead, each P represents a scaling of the data item by a power of ten. P elements can appear only as a contiguous string of Ps in either the leftmost or rightmost digit positions of a picture-string. If the V character is used, it must be to the left of all leading Ps or to the right of all trailing Ps. The assumed decimal point for the item is located at the point where the V character may be placed. For example, the PICTURE string 9P is a one-digit item that can have numeric values of 10, 20, ..., 90, and a PICTURE string of PPP9 is a one-digit item that can have numeric values of 0.0001 though 0.0009. The "." character may not be specified in the same picture-string as a P character. When a data item is treated as a numeric value, each P position acts as if it were a digit position that contained a zero. When a data item is not treated as a numeric value, then its P positions are ignored.
S Indicates the presence of an operational sign for a numeric item. It does not specify the sign representation or position. Only one S may appear in a PICTURE string, and it must be the leftmost character. It does not count in the size of the data item unless the SIGN IS SEPARATE clause is also specified.

Note that the PICTURE definition for a PIC X(n) COMP-5 cannot be signed.

V Specifies the location of an assumed decimal point. It may appear only once in a PICTURE string. It does not represent a character position and is not counted in the size of the data item.
X Represents a character position that can contain any character from the computer's character set. It is counted in the size of an item.
Z Represents a leading digit position that is replaced by a space when its value and the digit positions to its left are all zero. It is counted in the size of an item.
9 Represents a digit position which is counted in the size of an item.
0 Represents a digit position where a zero will be inserted. It is counted in the size of an item.
/ Represents a character position where a slash will be inserted. It is counted in the size of an item.
, The comma character represents a character position where a comma will be inserted. It counts in the size of an item.
. The period character represents a character position where a decimal point will be inserted. It also implies an operational decimal point for alignment purposes. It counts in the size of an item. Note that the functions of comma and period are exchanged if the DECIMAL-POINT IS COMMA clause is stated in the program's SPECIAL-NAMES paragraph.
+ - Represent editing sign control symbols. These can occur more than once. Each counts in the size of an item.
CR Represents an editing sign control symbol. It may be used only once on the rightmost side of the PICTURE string. It adds two to the size of a data item.
DB Represents an editing sign control symbol. It may be used only once on the rightmost side of the PICTURE string. It adds two to the size of a data item.
* Represents a leading digit that is replaced by asterisks when its value and all of the digits to its left are zero. It is counted in the size of an item.
$ Represents a character position into which the currency symbol is inserted. It is counted toward the size of an item. Note that the dollar sign is the default currency symbol. It may be changed by the CURRENCY clause of the SPECIAL-NAMES paragraph.

Editing Rules

  1. The two methods of editing

    There are two general methods of performing editing in the PICTURE clause, either by insertion or by suppression and replacement.

  2. The four types of insertion editing :
    • Simple insertion
    • Special insertion
    • Fixed insertion
    • Floating insertion
  3. The two types of suppression and replacement editing:
    • Zero suppression and replacement with spaces
    • Zero suppression and replacement with asterisks
  4. Types of editing allowed:

    The type of editing that may be performed on an item is dependent on the category of that item. No editing may be performed on alphabetic, numeric, or alphanumeric items. Simple insertion of types 0, B, and / may be performed on alphanumeric edited types. All forms of editing are allowed on numeric edited items.

  5. Floating insertion, zero suppression, and the PICTURE clause

    Floating insertion and zero suppression and replacement are mutually exclusive in a PICTURE clause. Only one type of zero suppression and replacement may be used in a PICTURE clause.

  6. Simple Insertion Editing

    The comma, B, 0, and / are used as simple insertion characters. The insertion characters represent positions in an item where those characters will be inserted. If the comma is the last symbol in a PICTURE clause, the PICTURE clause must be the last clause in its data description entry, and the clause must be immediately followed by a period.

  7. Special Insertion Editing

    The period is used as an insertion character, as it is in simple insertion. In addition to being used as an insertion character, it also represents the operational decimal point of the item. The period may not appear in the same PICTURE clause as the V symbol. If the period is the last symbol in the PICTURE clause, then the PICTURE clause must be the last clause in its data description entry, and the clause must be immediately followed by a period.

  8. Fixed Insertion Editing

    The currency symbol and the editing sign control symbols "+", "-", CR, and DB are the insertion characters. Only one currency symbol and only one of the editing sign control symbols can be used in a given PICTURE clause. The symbols CR and DB, when used, must appear as the rightmost symbols in the PICTURE string. The symbol "+" or "-", when used, must either be the leftmost or rightmost character position to be counted in the size of the item. The currency symbol must be the leftmost character except that it may be preceded by either a "+" or "-" symbol.

    Fixed insertion editing results in the insertion character's occupying the same character position in the edited item as it occupied in the PICTURE string. Editing sign control symbols produce the following results depending on the value of the data item:

    Editing Symbol Zero or Positive Negative
    + + -
    - space -
    CR 2 spaces CR
    DB 2 spaces DB
  9. Floating Insertion Editing

    The currency symbol and editing sign control symbols "+" and "-" are the floating insertion characters. They are mutually exclusive in a PICTURE clause. You indicate floating insertion by using a string of at least two of the floating insertion characters. This string may contain any of the simple insertion characters or have the simple insertion characters immediately to the right. These simple insertion characters are part of the floating string.

    The leftmost character of the floating insertion string represents the leftmost limit of the floating symbols in the data item. The rightmost character represents the rightmost limit. The second floating character from the left represents the leftmost limit of the numeric data that can be stored in the data item. Non-zero numeric data may replace all the characters at or to the right of this limit.

    In a PICTURE string, there are only two ways of representing floating insertion editing. One way is to represent any or all of the leading numeric character positions on the left of the decimal point by the insertion character. The other way is to represent all of the numeric character positions by the insertion character.

    If the insertion character positions are only to the left of the decimal point, the result is that a single floating insertion character will be placed into the character position immediately preceding either the decimal point or the first non-zero digit in the data represented by the insertion symbol string, whichever is leftmost. The character positions preceding the insertion character are replaced by spaces.

    If all numeric character positions in the PICTURE string are represented by the insertion character, the results depend on the value of the data. If the value is zero, the entire data item will contain spaces. If the value is not zero, then the results are the same as when the insertion character is only to the left of the decimal point.

    The character inserted for the "+" symbol is "+" if the value is zero or positive and "-" if it is negative. The character inserted for the "-" symbol is "-" if the value is negative and space otherwise.

  10. Zero Suppression and Replacement Editing

    The suppression of leading zeros in numeric character positions is indicated by the use of the "Z" and "*" symbols. These symbols are mutually exclusive in a PICTURE clause. If a "Z" is used, the replacement character is a space. If "*" is used, the replacement character is an asterisk.

    You indicate zero suppression and replacement by using a string of one or more of the allowable symbols to represent leading numeric character positions which are to be replaced when the associated character position in the data contains a leading zero. Any of the simple insertion characters embedded in the string of symbols or to the immediate right of this string are part of the string.

    In a PICTURE string, there are only two ways of representing zero suppression. One way is to represent any or all of the leading numeric character positions to the left of the decimal point by suppression symbols. The other is to represent all of the numeric character positions by suppression symbols.

    If the suppression symbols appear only to the left of the decimal point, any leading zero in the data that corresponds to a symbol in the suppression string is replaced by the replacement character.

    If all numeric positions in the PICTURE string are represented by suppression symbols and the value of the data is not zero, the result is the same as if the suppression characters were only to the left of the decimal point. If the value is zero and the suppression symbol is Z, the entire data item is set to spaces. If the suppression symbol is "*" instead, the entire data item is set to asterisks except for the decimal point (if any), which will appear in the data item.

  11. The symbols "+", "-", "*", Z, and the currency symbol, when used as floating replacement characters, are mutually exclusive in a given PICTURE clause.