The PICTURE clause describes the General characteristics, editing requirements, and format validation profile of an elementary item.
Format 1 (basic):
Format 2 (locale):
Character-string-1 shall consist of an allowable combination of characters used as picture symbols.
The allowable combinations of symbols for a PICTURE clause are specified in 13.18.40.6, Precedence rules.
NOTE 1 The currency symbol can be selected from the set of allowable characters from the computer's compile-time coded character set. All picture symbols other than the currency symbol are from the COBOL character repertoire.
CURRENCY SIGN clause or a basic letter character A, B, C, D, E, N, P, R, S, V, X, Z or their lowercase equivalents.If literal-1 is specified, character-1 is a fixed editing sign control symbol. If the FOR phrase is specified, character-1 is an extended editing sign control symbol, character-1 is limited to numeric or numeric-edited data items, and the following rules apply:
If the FOR phrase is not specified, the following rules apply:
Character-string-1 shall contain:
NOTE 2 The symbols ‘CR’ and ‘DB’ although consisting of two characters, are each considered to be a symbol by itself.
The editing sign control symbols '+', '-', 'CR', and 'DB' are mutually exclusive in character-string-1 with the exception of a numeric-edited data item for a floating-point edited result as described in General rule 13b.
NOTE 3 For a floating-point edited result, the significand part of the character-string may contain a '-' symbol and the exponent part always contains a '+' symbol.
For fixed editing sign control, the currency symbol, when used, shall be either the leftmost symbol in character-string-1, optionally preceded by one of the symbols '+' or '-', or the rightmost symbol in character-string-1, optionally followed by one of the symbols '+', '-', 'CR', or 'DB'. For extended editing sign control, the currency symbol when used shall be either the leftmost symbol in character-string-1, optionally preceded by character-1, or the rightmost symbol in character-string-1 optionally followed by character-1.
NOTE 4 This means that the following are valid picture character-strings:
'+999$'
'+$999'
'999$+'
'+$$99'
'$$99+
No more than one of the following may be specified in character-string-1:
NOTE 5 This means, for example, that the picture character-string +$$$ is valid, but that the picture character-string +++$$$ is invalid.
A PICTURE clause defines the subject of the entry to fall into one of the following categories of data:
A BLANK WHEN ZERO clause specified for the subject of the entry defines the item as numeric-edited.
To define an item as alphanumeric, character-string-1 shall contain a combination of symbols from the set 'A', 'X', and '9', that includes
To define an item as alphanumeric-edited, character-string-1 shall include
To define an item as national-edited, character-string-1 shall include
To define an item as fixed-point numeric, character-string-1
To define an item as numeric-edited, one of the following options shall be specified:
To define a fixed-point numeric-edited item, character-string-1 shall include:
To define a floating-point numeric-edited item, characters-string-1 shall consist of two parts, separated without any spaces, by the symbol 'E'. The first part represents the significand; the second part represents the exponent.
The significand shall be a valid character-string for either a numeric item or a numeric-edited item for a fixed-point result. Neither floating insertion editing nor zero suppression with replacement shall be specified for the significand.
The exponent shall be '+9', '+99', '+999', '+9999', or '+9(n)' where n = 1, 2, 3, or 4.
The meaning of the symbols used in character-string-1 are as follows:
Each symbol 'A' represents a character position that shall contain any character from the computer's alphanumeric character set. Each symbol 'A' is counted in the size of the item.
The characters represented may be graphic characters or non-graphic characters.
NOTE 1 The symbol ‘A’ is equivalent to the symbol ‘X’ except within the execution of a VALIDATE statement. The meaning of the symbol ‘A’ within the VALIDATE statement is specified in General rule 15, below.
The symbol 'E' represents a character position into which the character 'E' will be inserted during editing. The symbol 'E' is counted in the size of the item.
The symbol 'E' is used to separate the significand and the exponent of a floating-point numeric-edited item.
The symbol 'P' specifies the location of an assumed decimal point when that point is not within the number that appears in the data item. The symbol 'P' is not counted in the size of the item, but each symbol 'P' is counted in the maximum number of digit positions.
The symbol 'P' implies an assumed decimal point that is either
In certain operations that reference a data item whose picture character-string contains the symbol 'P', the algebraic value of the data item is used rather than the actual value of the data item. This algebraic value assumes the decimal point in the prescribed position and zero in place of each digit position specified by the symbol 'P'. The size of the value is the number of digit positions represented by the picture character-string.
The operations that use the algebraic value are the following:
In all other operations, the digit positions specified with the symbol 'P' are ignored and are not counted in the size of the operand.
The symbol 'V' indicates the position of the assumed decimal point for alignment purposes. The symbol 'V' is not counted in the size of the item.
When the assumed decimal point position is to the right of the rightmost digit position, the symbol 'V' is redundant.
Each symbol 'X' represents a character position that shall contain any character from the computer's alphanumeric character set. Each symbol 'X' is counted in the size of the item.
The characters represented may be graphic characters or non-graphic characters.
The symbol '.' (period) represents a character position into which the character period will be inserted during editing. The symbol '.' is counted in the size of the item.
In addition, the symbol '.' indicates the decimal point position for alignment purposes.
A currency symbol represents character positions into which the currency string will be placed during editing. A currency symbol is represented in character-string-1 either by the currency sign or by the currency symbol specified in a CURRENCY SIGN clause in the SPECIAL-NAMES paragraph.
The first occurrence of the currency symbol adds the number of characters in the currency string to the size of the item. Each subsequent occurrence of the currency symbol adds one to the size of the item.
Character-1 in character-string-1 represents a character position into which the associated literal-1, literal-2, or literal-3 is to be placed. If character-1 is a simple insertion symbol or a fixed insertion symbol, the size of literal-1 is counted in the size of the item. For fixed editing sign control symbols, each character used in the symbol is counted in the size of the item. For extended editing sign control symbols with fixed insertion, each occurrence of the character(s) specified in the associated literal are counted in the size of the item. For floating inserting, one occurrence of literal-2 or literal-3 is counted in the size of the item plus one character for each repetition of character-1.
NOTE 2 If reference modification is used to reference part of a data item described with floating extended editing sign control symbols, care is needed to account for the repetitions.
The PICTURE clause takes effect during the format validation stage of the execution of a VALIDATE statement that refers directly or indirectly to the subject of the entry.
[Validation rules omitted.]
The meaning of the symbols used in character-string-1 are as follows:
The symbol '.' (period) represents a character position into which the decimal separator taken from the locale will be inserted during editing.
In addition, the symbol '.' indicates the decimal point position for alignment purposes.
There are two methods of performing editing: either insertion or suppression with replacement.
There are four types of insertion editing:
There are two types of suppression with replacement:
The type of editing that may be performed upon an item is dependent upon the category to which the item belongs. Table 7, Category and type of editing, specifies which type of editing may be performed upon a given category:
| Category | Type of editing |
|---|---|
| Alphabetic | None |
| Alphanumeric | None |
| Boolean | None |
| National | None |
| Numeric | None |
| Alphanumeric-edited | Simple insertion |
| National-edited | Simple insertion |
| Numeric-edited (fixed-point edited result) | All |
| Numeric-edited (floating-point edited result) | Simple insertion, special insertion, and fixed insertion for the significand part None for the exponent part |
Simple insertion editing
Character-1 and the symbols 'B', '0', '/', ',' and, if literal-1 is specified, character-1 are used as the simple insertion editing symbols.
Simple insertion editing results in the insertion character occupying the same character position in the edited item as the associated symbol occupies in character-string-1.
Special insertion editing
The symbol '.' is used as the special insertion editing symbol.
Special insertion editing results in the period character occupying the same character position in the edited item as the symbol '.' occupies in character-string-1.
Fixed insertion editing
Character-1, the currency symbol and the editing sign control symbols '+', '-', 'CR' and 'DB' are used as the fixed insertion editing symbols.
Fixed insertion editing results in the insertion character(s) occupying the same character position(s) in the edited item as the associated symbol occupies in character-string-1.
When character-1 is used, and is not a simple insertion character, it represents literal-2, or literal-3 as the insertion characters.
Table 8, Results of fixed insertion editing, shows the character(s) produced by an editing sign control symbol, depending on the value of the data item.
| Editing symbol | Result | |
|---|---|---|
| Positive or zero value | Negative value | |
| + | + | – |
| – | space | – |
| CR | 2 spaces | CR |
| DB | 2 spaces | DB |
| character-1, NEGATIVE phrase | literal-2 | literal-2 or spaces |
| character-1, POSITIVE phrase | literal-3 or spaces | literal-3 |
| Literal-2 or literal-3 or spaces means one instance of literal-2 or literal-3 or as many spaces as there are characters in literal-2 or literal-3. | ||
The uppercase letters CR and DB are the insertion characters for the insertion symbols 'CR' and 'DB'.
Floating insertion editing
The currency symbol, the extended editing sign control symbols, if specified, and the fixed editing sign control symbols '+' and '-' are used as the floating insertion symbols.
Floating insertion editing is indicated by specifying a string of at least two identical floating insertion editing symbols. Any of the simple insertion editing symbols embedded in this string or to the immediate right of this string are part of the string.
The leftmost symbol of the insertion string represents the leftmost limit of the floating characters in the data item. The rightmost symbol of the insertion string represents the rightmost limit of the floating characters in the data item.
The second floating symbol represents the leftmost limit of the numeric data that may be stored in the item. During editing, nonzero numeric characters may replace all the insertion symbols at or to the right of this limit.
If truncation occurs, the value of the data that is used for editing is the value after truncation as specified in 14.6.8, Alignment and transfer of data into data items
NOTE 1 If the size of character-string-1 is not at least the number of characters in the sending operand, plus the number of non-floating insertion symbols to be inserted in the item, plus one. unwanted truncation of data can result.
There are two ways of representing floating insertion editing:
One way is to represent any or all of the leading numeric character positions to the left of the decimal point position by the same insertion symbol. The result is that a single occurrence of the replacement character(s) is (are) placed into the character position(s) immediately preceding whichever of the following is encountered first:
Any character positions preceding this (these) insertion character(s) will contain the space character.
Table 9, Results of floating insertion editing, shows the character produced by the floating editing sign control symbols ‘es’, '+' and '-', depending on the value of the data item.
| Editing symbol in picture character-string |
Result | |
|---|---|---|
| Data item positive or zero |
Data item negative |
|
| + | + | – |
| – | space | – |
| character-1 NEGATIVE phrase | literal-2 or spaces | literal-2 |
| character-1 POSITIVE phrase | literal-3 | literal-3 or spaces |
Zero suppression with replacement editing
The symbols 'Z' and '*' are used as the symbols for zero suppression with replacement. If the symbol 'Z' is used, the replacement character is the character space; if the symbol '*' is used, the replacement character is the character asterisk.
Zero suppression with replacement is indicated by specifying a string of one or more identical zero-suppression characters. Any of the simple insertion editing symbols embedded in this string or to the immediate right of this string are part of the string.
There are two ways of representing zero suppression with replacement:
One way is to represent any or all of the leading numeric character positions to the left of the decimal point position by the zero-suppression symbol. The result is that the corresponding replacement character is placed into any character position immediately preceding whichever of the following is encountered first:
Zero value of a floating-point edited item
If the value to be edited into a floating-point edited item is zero, then after editing all digit positions of the significand and all digit positions of the exponent shall be zero; the sign of the significand, if present, shall be positive; and the sign of the exponent shall be positive.
[Editing rules 9–15 omitted.]
Where an 'x' appears in Table 10 and in Table 11, additional syntax rules or general rules may apply further restrictions.
Table 10, Format 1 picture symbol order of precedence, shows the order of precedence of symbols in a Format 1 picture character-string. An 'x' at an intersection indicates that the symbol(s) at the top of the column may precede (but not necessarily immediately) in character-string-1 the symbol(s) at the left of the row. The currency symbol is indicated by the symbol 'cs'.
The currency symbol when used as a fixed insertion symbol appears in two columns and two rows. The leftmost column and the uppermost row for this symbol represent its use as the first or second symbol in character-string-1. The rightmost column and the lowermost row for this symbol represent its use as the last or penultimate symbol in character-string-1.
The symbol '+' that appears in a column and in a row by itself, represents its use in the exponent part of character-string-1 for a floating-point numeric-edited item.
The symbols '+' and '–' when used as a non-floating insertion symbol appear in two columns and two rows. The leftmost column and the uppermost row for these symbols represent their use as the first symbol in character-string-1. The rightmost column and the lowermost row for these symbols represent their use as the last symbol in character-string-1.
The symbol 'P', the currency symbol when used as a floating insertion symbol, the pair of zero-suppression symbols 'Z' and '*', and the pair of floating insertion symbols '+' and '–' appear in two columns and in two rows in Table 10. The leftmost column and the uppermost row for these symbols represent their use to the left of the decimal point position. The rightmost column and the lowermost row for these symbols represent their use to the right of the decimal point position.
For the purposes of Table 10, character-string-1 for a numeric-edited item for a floating-point edited result is considered as two separate strings, the first of which begins with the first symbol and ends with the symbol 'E', and the second of which begins with the symbol 'E' and ends with the last symbol. The presence of symbols preceding the symbol 'E' has no effect on the validity of symbols following the symbol 'E'.
When the DECIMAL-POINT IS COMMA clause is specified, the precedence rules for the symbols comma and period are interchanged.
| Second Symbol |
First Symbol | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Simple, special, and fixed insertion symbols |
Zero-suppression and floating insertion symbols |
Other symbols | |||||||||||||||||||||||
| B 0 / |
, | . | + | + – |
+ – |
C R D B |
c s |
c s |
Z * |
Z * |
+ – |
+ – |
c s |
c s |
9 | A X |
S | V | P | P | 1 | N | E | ||
| Simple, special, and fixed insertion symbols | B 0 / | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | ||||||||
| , | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |||||||||||
| . | x | x | x | x | x | x | x | x | x | ||||||||||||||||
| + | x | ||||||||||||||||||||||||
| + – |
|||||||||||||||||||||||||
| + – |
x | x | x | x | x | x | x | x | x | x | x | x | x | ||||||||||||
| CR DB |
x | x | x | x | x | x | x | x | x | x | x | x | x | ||||||||||||
| cs | x | ||||||||||||||||||||||||
| cs | x | x | x | x | x | x | x | x | x | x | |||||||||||||||
| Zero-suppression and floating insertion symbols | Z * |
x | x | x | x | x | |||||||||||||||||||
| Z * |
x | x | x | x | x | x | x | x | x | ||||||||||||||||
| + – |
x | x | x | x | |||||||||||||||||||||
| + – |
x | x | x | x | x | x | x | ||||||||||||||||||
| cs | x | x | x | x | |||||||||||||||||||||
| cs | x | x | x | x | x | x | x | ||||||||||||||||||
| Other symbols | 9 | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | |||||||||
| A X |
x | x | x | ||||||||||||||||||||||
| S | |||||||||||||||||||||||||
| V | x | x | x | x | x | x | x | x | x | x | |||||||||||||||
| P | x | x | x | x | x | x | x | x | x | x | |||||||||||||||
| P | x | x | x | x | x | ||||||||||||||||||||
| 1 | x | ||||||||||||||||||||||||
| N | x | x | |||||||||||||||||||||||
| E | x | x | x | x | x | ||||||||||||||||||||
If the EDITING phrase is specified, the precedence of ‘es’ as related to Table 10, Format 1 picture symbol order of precedence, has the same precedence as the 'cs' symbol in the column and row of non-floating insertion symbols.
Table 11, Format 2 picture symbol order of precedence, shows the order of precedence of symbols in a Format 2 picture character-string. An 'x' at an intersection indicates that the symbol at the top of the column may precede (but not necessarily immediately) in character-string-1 the symbol at the left of the row. The currency symbol is indicated by the symbol 'cs'.
| Second Symbol |
First Symbol | ||||
|---|---|---|---|---|---|
| 9 | cs | . | + | Z | |
| 9 | X | X | X | X | X |
| cs | X | ||||
| . | X | X | X | X | |
| + | |||||
| Z | X | X | X | X | |