Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

PICTURE clause

Function

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

Format


{PICTURE | PIC}  IS character-string


Syntax rules

  1. PIC is the abbreviation of PICTURE.

  2. A character-string consists of certain allowable combinations of the characters in the COBOL character set. These combinations determine the category of data to which an elementary item belongs.

  3. There are 18 characters or symbols that may be used in a character-string: A, N, comma (,), X, 9, P, Z, *, B, 0, +, minus (-), currency symbol ($), slash (/), S, V, period (.), credit (CR), and debit (DB). The functions of each character and symbol are described below under "Summary of characters and symbols in the PICTURE character-string".

  4. The characters S, V, ., CR, and DB may appear only once in a PICTURE clause.

  5. An integer enclosed in parentheses can follow the symbols A, N, comma (,), X, 9, P, Z, *, $, B, slash (/), 0, minus (-), and plus (+), to indicate the number of consecutive occurrences of the symbol. The number in parentheses must be at least 1 and must not exceed 131071.

  6. At least one of the symbols A, N, X, Z, 9, or *, or at least two of the symbols +, -, or CS
    1)
    must be present in a character-string.

  7. The maximum number of characters allowed in a character-string is 50. This does not limit the number of characters in the described elementary item which may be much more than 50.

  8. The allowable combinations of symbols used in a character-string are shown in table 14.
    An X at an intersection means that, in a character-string, the "second symbol" specified in the associated column may be located at any position to the right of the "first symbol" located at the start of the row. The leftmost column and uppermost row for each symbol represent its use to the left of the decimal point position (l). The rightmost column and lowermost row for each symbol represent its use to the right of the decimal point position (r).









    First symbol

    Second symbol

    Non-floating insertion symbols

    Floating insertion symbols

    Other symbols

    B
    0
    /



    ,



    .


    +

    -


    +

    -


    CR

    DB



    CS1)


    Z

    *


    Z

    *


    +

    -


    +

    -



    CS1)



    CS1)



    9


    A

    X



    S



    V



    P



    P



    N




    l

    r



    l

    r

    l

    r

    l

    r





    l

    r


    Non-

    float.
    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







    + -

    l

    X

    X

    X




    X

    X

    X



    X

    X

    X



    X

    X

    X


    + -

    r





















    CR / DB






















    CS1)


    X

    X

    X


    X

    X


    X

    X

    X

    X



    X



    X

    X

    X


    Float.

    insertion
    symbols

    Z *

    l

    X

    X

    X


    X

    X


    X

    X





    X



    X

    X



    Z *

    r

    X

    X



    X

    X



    X












    + -

    l

    X

    X

    X







    X

    X



    X



    X

    X



    + -

    r

    X

    X









    X










    CS1)

    l

    X

    X

    X

    X


    X






    X

    X

    X




    X

    X


    CS1)

    r

    X

    X

    X



    X







    X








    Other

    symbols

    9


    X

    X

    X


    X

    X








    X

    X


    X

    X



    A X


    X













    X

    X






    S















    X



    X

    X

    X


    V


    X

    X



    X

    X



    X


    X


    X

    X





    X


    P

    l





    X

    X











    X

    X



    P

    r

    X

    X



    X

    X



    X


    X


    X

    X





    X


    N





















    X


    Table 14: Precedence of symbols used in the PICTURE clause

    1)CS is the abbreviation for currency symbol.

  9. The number of characters specified in the character-string is used to determine the size of the item. However, the actual internal storage requirements are determined by the combination of the PICTURE and USAGE clauses (see section "USAGE clause").

  10. Data in following categories may be described with the PICTURE clause:
    • alphabetic

    • alphanumeric

    • alphanumeric edited

    • national

    • numeric

    • numeric edited

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

    The following types of insertion editing are available:

    • simple insertion

    • special insertion

    • fixed insertion

    • floating insertion

    Two types of suppression and replacement editing are available:

    • zero suppression and replacement with spaces

    • zero suppression and replacement with asterisks (*).

General rule

  1. The PICTURE clause is permitted only for elementary items.

Summary of characters and symbols in a PICTURE character-string

The characters and symbols that are permitted in a character-string have the following meaning:

A

Each A in the character-string represents a character position that may contain only a letter or a space.

B

Each B in the character-string represents a character position into which a space character will be inserted. Each space is counted in the size of the item.

N

Each N in the PICTURE character-string represents a character position which can contain any character from the UTF-16 character set.

P

P represents a numeric digit position which is counted in the number of character positions; however, storage space is not reserved for it. At the same time it shows the position of the conceptual assumed decimal point:

  • to the left of the Ps if Ps are the leftmost characters of the character-string

  • to the right of the Ps if the Ps are the rightmost characters of the character-string

In some operations which address an elementary item whose PICTURE character-string contains the character P, the actual content of the data item is replaced by its algebraic value. For the algebraic value each P is treated as if it contained a zero and the decimal point were at the specified position.
Operations which use the algebraic value:

  • Every operation which requires a numeric sending item.

  • An elementary MOVE statement (elementary move) with numeric sending item whose PICTURE character-string contains one or more Ps.

  • A MOVE statement with numerically edited sending item whose character-string contains one or more Ps and a numeric or numeric-edited receiving item.

  • A comparison operation in which both operands are numeric.

In all other operations the digit positions described with the character P are ignored and not included in the size of the data item.

S

The character S indicates the presence but not the location or mode of representation of an operational sign. If used, it must be the leftmost character of the character-string. The S is not counted in the size of the item unless the entry is subject to a SIGN clause which specifies the SEPARATE CHARACTER phrase.

V

The character V indicates the position of an assumed decimal point. Since a numeric item cannot contain a printed decimal point, an assumed decimal point simply provides the compiler with information about the scaling alignment of items involved in computations. Storage is never reserved for the character V; therefore, V is not counted in the size of the item. If the assumed decimal point is the rightmost character in the character-string, the character V need not be supplied.

X

Each X in the character-string represents a character position which may contain any allowable character from the EBCDIC set.

Z

Each Z in the character-string represents a leading numeric character position. If such a character position contains a zero, then the zero is replaced by a space. Each Z is counted in the size of the item.

9

Each 9 in the character-string represents a character position that contains a numeral and is counted in the size of the elementary data item.

0

Each zero in the character-string represents a character position into which the numeral zero will be inserted. Each zero is counted in the size of the item.

/

Each slash (/) in the character-string represents a character position into which a slash will be inserted. Each slash is counted in the size of the item.

,

Each comma (,) in the character-string represents a character position into which a comma is inserted. Each comma is counted in the size of the elementary data item.

.

A period (.) in the character-string is an editing symbol and represents the decimal point used for alignment of the elementary data item. Additionally, it represents a character position into which a period is inserted. The period is counted in the size of the elementary data item.

Note

In a given program, the functions of the period and the comma are exchanged if the DECIMAL-POINT IS COMMA clause is specified in the SPECIAL-NAMES paragraph of the ENVIRONMENT DIVISION. The rules for the period then apply to the comma, and vice versa, whenever they appear in a PICTURE character-string.

+
-
CR
DB

These symbols are used as editing sign control symbols. When used, each represents the character position into which the editing sign control will be placed. These symbols are mutually exclusive in any one character-string, and each character used in the symbol is counted in determining the size of the elementary data item. Editing sign control symbols produce different results for positive and negative elementary data items, depending on the value (see "Fixed insertion editing").

*

This symbol is a check protection symbol. Each asterisk (*) in the character-string
represents a leading numeric character position into which an asterisk will be placed if that position contains a zero. Each asterisk (*) is counted in the size of the item.

If the asterisk is used together with the BLANK WHEN ZERO clause in a data description entry, the print editing routine cancels the effect of the BLANK WHEN ZERO clause since it suppresses any zeros.

$

The currency symbol ($) in the character-string represents a character position into which a currency sign is to be placed. The currency symbol in a character-string is represented either by the symbol $ or by the single character specified in the CURRENCY SIGN clause in the SPECIAL-NAMES paragraph of the ENVIRONMENT DIVISION. The currency symbol is counted in the size of the item.

Alphabetic elementary data items

Syntax rules

  1. Only the symbol A is allowed in the character-string of an alphabetic item.

  2. Any combination of the 52 letters of the alphabet and the space may be specified as the contents of an alphabetic elementary data item.

Example 7-10

Picture

PICTURE AAA

Value

NEW

Alphanumeric elementary data items

Syntax rules

  1. The character-string for an alphanumeric elementary data item is restricted to certain combinations of the following symbols: A, X, 9.

    An alphanumeric item is treated as if its character-string contained all Xs, with each X representing one character position.

  2. A character-string that contains all As or 9s does not define an alphanumeric item.

Example 7-11

The alphanumeric value AB1234 could be represented by any of the following character-strings:

PICTURE XXXXXX
PICTURE AAXXXX
PICTURE AA9999
PICTURE A(2)X(4)


National elementary data items

Syntax rule

  1. The character-string for a national elementary data item is restricted to certain the symbol N.

Numeric elementary data items

There are two types of numeric elementary data items: fixed-point items and floating-point items.

Fixed-point items

There are three types of fixed-point items: external decimal, binary, and internal decimal (see section "USAGE clause").

Syntax rules

  1. The character-string for a fixed-point elementary data item may contain any permissible combination of the following symbols: 9, V, P, S.

  2. It can contain from 1 up to and including 31 digit positions.

  3. If the symbol S has not been specified, a elementary data item may contain a combination of the digits 0 through 9.

  4. If the symbol S has been specified, the elementary data item may contain, in addition to the above digits, a +, - or other representation of an arithmetic sign (see  "SYNCHRONIZED clause").

Example 7-12

Valid combinations for fixed-point items:

PICTURE 9999
PICTURE S99
PICTURE S99V9
PICTURE PPP999
PICTURE S999PPP

Example 7-13

Let 8735 be the contents of a elementary data item.

For PICTURE P(4)9(4), the arithmetic value of this item is .00008735.

For PICTURE 9(4)P(2), the arithmetic value of this item is 873500.

Floating-point elementary data items

There are two types of floating-point elementary data items: internal and external floating-point items (see section "USAGE clause").

Syntax rules

  1. The character-string for an external floating-point item has the following format:

    { + | - } mantissaE { + | - } exponent

    where the following rules are to be observed for the elements of the character-string:

    A positive or negative sign must be written immediately in front of the mantissa and the exponent in the character-string.

    +

    indicates that a plus sign is to represent positive values and a minus sign is to represent negative values.

    -

    indicates that a blank is to represent positive values and a minus sign is to represent negative values.

    mantissa

    The mantissa is the decimal part of the number after the decimal point; it consists of 1 to 18 ’9’s (each 9 representing a numeric character) and a leading, embedded, or trailing decimal point (.) or V. The decimal point indicates an actual (printed) decimal point, and the V indicates an assumed decimal point; these two characters are mutually exclusive.

    E

    immediately follows the mantissa and indicates that an exponent follows.

    exponent

    The exponent immediately follows the second sign and consists of two consecutive 9s.

  2. The PICTURE clause must not be specified for an internal floating-point item.

Example 7-14 External floating-point item

    PICTURE   -9V99E-99
    PICTURE   +9999.99E+99
    PICTURE   -9(16)VE+99
    PICTURE   +9(16).E-99


Alphanumeric edited elementary data items

Syntax rules

  1. The character-string for an alphanumeric edited elementary data item is restricted to certain combinations of the following symbols: A, X, 9, 0, B, / (slash).

  2. An alphanumeric edited character-string must contain at least one A or X, and at least one B or 0 or / (slash).

  3. Only one type of editing is performed on alphanumeric edited elementary data items: simple insertion editing using the characters zero (0), slash (/) and space (B) (see rules for simple insertion editing, "PICTURE clause").

Example 7-15

Picture

Value

PICTURE BAAAB

'BLANK'NEW'BLANK'

Numeric edited elementary data items

Syntax rules

  1. The character-string for a numeric edited elementary data item is restricted to certain combinations of the following symbols:
    B, / (slash), P, V, Z, 0, 9, , (comma), . (period), *, +, -, CR, DB, $.

  2. The character-string must contain at least one of the symbols:
    0, B, / (slash), Z, *, +, , (comma), . (period), -, CR, DB or $.

  3. The maximum number of digit positions in the character-string is 31.

  4. The maximum length of a numeric edited elementary data item is 127 characters.

  5. Allowable combinations of these characters are governed by the editing rules and the symbol precedence rules (see following syntax rules and table 14).

Simple insertion editing

Syntax rules

  1. In simple insertion editing, the following insertion characters are used: , (comma), B (space), 0 (zero), and / (slash).

  2. The insertion characters are counted in the size of the item, and represent the positions within the item into which they will be inserted.

Example 7-16

Category of data

PICTURE string
receiving item

Data being moved

Edited result

Numeric edited

 999,999

99B99B99

99B99B00

99/99/99

 54321

654321

654321

654321

054,321

65'BLANK'43'BLANK'21

43'BLANK'21'BLANK'00

65/43/21

Alphanumeric
edited

XXBXXX

000X(5)

XX/XX

123AA

A5CD3

CD05

12'BLANK'3AA

000A5CD3

CD/05

Special insertion editing

Syntax rules

  1. Special insertion editing is performed by using the period (.) as an insertion character.

    In addition to being used as the insertion character, the period is also used as the decimal point for alignment purposes.

  2. The assumed decimal point (represented by the character V) and the actual (printed) decimal point cannot be used in the same character-string.

  3. Special insertion editing may be used on numeric edited elementary data items only.

  4. As a result of special insertion editing, the insertion character (decimal point) appears in the item in the same position as shown in the character-string; thus, the insertion character is the actual decimal point. The actual decimal point is counted in the size of the item.

Example 7-17

PICTURE string of receiving item

Data being moved *)

Edited result

999.99
999.99
999.99
999.99

123&4
12&34
1&234
&1234

123.40
012.34
001.23
000.12

*) & designates the position of the assumed decimal point, which does not appear in the MOVE operation.

Fixed insertion editing

Syntax rules

  1. The editing symbols used for fixed insertion editing are:
    + (plus), - (minus), CR (credit), DB (debit), and $ / € (currency symbol).

  2. Only one currency symbol and only one of the editing sign control symbols (+, -, CR, DB) may be used in a given character-string.

  3. The currency symbol may be preceded only by a plus or a minus symbol; otherwise, it must be the leftmost character.

  4. The symbols CR or DB, when specified, must be either the leftmost or the rightmost character.

  5. The plus or minus symbol, when specified, must be either the leftmost or the rightmost character.

  6. Fixed insertion editing results in the editing character occupying the same character position in the edited item as in the character-string.

  7. The symbols CR or DB, when used, represent two character positions which are counted in the size of the elementary data item. All fixed insertion editing characters are counted in the size of the elementary data item.

  8. Editing sign control symbols produce the results listed in table 15, depending on the value of the elementary data item (see table 15).

Editing symbol in PICTURE character-string

elementary data item positive or zero

elementary data item negative

+
-
CR
DB

+
space
2 spaces
2 spaces

-
-
CR
DB

Table 15: Editing sign control symbols and their results

Example 7-18

PICTURE string of receiving item

Data being moved *)

Edited result

+999.99

+999.99

-999.99

-999.99

$999.99CR

$999.99CR

$999.99DB

$999.99DB

+123&45

-123&45

+123&45

-123&45

+123&45

-123&45

+123&45

-123&45

+123.45

-123.45

123.45

-123.45

$123.45

$123.45CR

$123.45

$123.45DB

*) & designates the position of the assumed decimal point, which does not appear in the MOVE operation.

Floating insertion editing

Syntax rules

  1. In floating insertion editing, the currency symbol ($) and the editing sign control symbols (+ and -) are used as insertion characters. These characters are mutually exclusive as floating insertion characters in the same character-string.

    Floating insertion editing is indicated in a character-string by the use of a sequence of at least two of the allowable insertion characters to represent the leftmost numeric character positions into which the insertion characters can be floated. Any of the simple insertion characters (, B 0 /) embedded in the sequence of floating insertion characters or to the immediate right of this sequence are part of this floating string.

  2. Only two types of floating insertion editing may be specified in a character-string.:

    • Some or all of the leading numeric character positions to the left of the decimal point may be represented by insertion characters.

    • All of the numeric character positions of the character-string may be represented by insertion characters.

  3. The result of floating insertion editing depends on the representation in the character-string:

    • If the insertion characters are specified only to the left of the decimal point, a single insertion character is placed into the character position which immediately precedes the decimal point, or the first non-zero digit to the left of the character-string, and which is located inside the data represented by the insertion symbol string. The character positions preceding the insertion character are replaced with spaces.

    • If each of the numeric character positions in the character-string is represented by the insertion character, the result depends on the value of the elementary data item concerned. If the value is zero, the entire data will contain spaces. If the value of the item is not zero, the result is the same as that occurring when the insertion characters are specified only to the left of the decimal point.

  4. Every floating insertion character is counted in the size of the elementary data item.

  5. To avoid truncation of character positions, the programmer must form the character-string for the receiving item according to the following rule:

    • The minimum size of the character-string must equal the number of non-floating insertion characters which are used for editing in the receiving item, plus one floating insertion character.

Example 7-19

Receiving area PICTURE

Data being moved*)

Edited result

$$$$.99
$$$$.99
$$$$.99
$,$$$.99
$,$$$.99
$,$$$.99
+,+++.99
+,+++.++
$,$$$.99
-,---.99
-,---.99
$$,$$$.99
+,+++,999.99
+,+++,+++.++

123&12
3&12
&12
123&12
3&12
&12
123&12
123&12
-123&12
-123&12
123&12
1234&56
-123456&78
000&00

$123.12
$3.12
$.12
$123.12
$3.12
$.12
+123.12
+123.12
$123.12
-123.12
'BLANK'123.12
$1,234.56
-123,456.78
(blank)

*) & designates the position of the assumed decimal point which does not appear in the MOVE operation.

Zero suppression and replacement editing

Syntax rules

  1. Suppression of leading zeroes in numeric character positions is indicated by the use of the alphabetic character Z or the character * (asterisk) as suppression symbols in a PICTURE character-string. These characters are mutually exclusive in the same character-string. If Z is used, the replacement character is a space. If * is used, the replacement character is a space. If * is used, the replacement character is * (asterisk).

  2. Zero suppression and replacement editing in a character-string is achieved by using a string of one or more of the permissible symbols (* or Z) to represent leading numeric character positions which are to be filled with the replacement characters when the associated character positions in the data contain zeros. Any of the simple insertion characters (, B 0 /) embedded in the string of symbols or to the immediate right of the string are part of the string; each of these simple insertion characters works like an * or a Z, until a non-zero character is encountered. The simple insertion characters (, B 0 /) and fixed insertion characters ($ + -) to the left of the suppression string are not subject to the rules for zero suppression and replacement.

  3. Two types of zero suppression editing may be used in a character-string.

    • Some or all of the leading numeric character positions to the left of the decimal point may be represented by suppression symbols.

    • All of the numeric character positions in the character-string may be represented by suppression symbols.

  4. The result of zero suppression and replacement editing depends on the representation in the character-string:

    • If the suppression symbols appear only to the left of the decimal point, any leading zero in the data which corresponds to a suppression symbol in the string is replaced by the replacement character. Suppression terminates at the first non-zero digit in the data represented by the suppression symbol string or at the decimal point.

    • If all numeric character positions in the character-string are represented by suppression symbols and the value of the elementary data item 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 elementary data item is replaced by spaces. If the value is zero and the suppression symbol is *, all characters in the elementary data item, except for the decimal point, are replaced by asterisks; in this case, zero suppression editing overrides the BLANK WHEN ZERO clause, if the latter is specified.

  5. Each suppression character is included in the size of the elementary data item.

Example 7-20

Receiving area PICTURE

Data being moved*)

Editing result

ZZZZ.ZZ

****.**

ZZZZ.99

****.99

ZZZZ.ZZ

$**,***.**BDB

$BB****,**.99BBCR

0000&00

0000&00

0000&00

0000&00

+135&00

-2135&00

-2135&00

'BLANK'(x7)

****.**

'BLANK''BLANK''BLANK''BLANK'.00

****.00

'BLANK'135.00

$*2,135.00'BLANK'DB

$'BLANK''BLANK'**21,35.00'BLANK''BLANK'CR

*) & designates the position of the assumed decimal point which does not appear in the MOVE operation.