[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index

5.3.37 PICTURE

Function

The PICTURE clause specifies the general characteristics and editing requirements of an elementary item, including an elementary screen item.


Syntax Rules (Both Formats)

  1. You can use the PICTURE clause only for an elementary item.
  2. character-string contains allowable combinations of characters in the COBOL character set. These characters are called the symbols of the PICTURE character-string.
  3. character-string can contain from 1 to 255 symbols.
  4. PIC is an abbreviation for PICTURE.
  5. The asterisk (*), when used as a zero suppression symbol, and the BLANK WHEN ZERO clause cannot be used in the same entry.

Syntax Rule (Format 1)

  1. The PICTURE clause is required for every elementary item except an item specified by the USAGE IS BINARY-CHAR, BINARY-SHORT, BINARY-LONG, BINARY-DOUBLE, COMP-1, COMP-2, FLOAT-SHORT, FLOAT-LONG, FLOAT-EXTENDED, POINTER, or INDEX clause and the subject of a RENAMES clause. Data description entries for these items cannot contain a PICTURE clause.

Syntax Rules (Format 2)

  1. The PICTURE clause for a numeric screen item must either define a numeric edited item or must contain only "9"s and an optional "S".
  2. Each PICTURE clause in a screen description entry must contain a FROM or a TO phrase, or both, or a USING phrase.
  3. In a screen description entry, if the PICTURE clause is specified, the VALUE clause cannot be specified.
  4. identifier-3, identifier-4, and identifier-5 must be defined in the File, Working-Storage, or Linkage Section.

General Rules (Both Formats)

  1. The PICTURE clause categorizes a data item or screen item and determines what the item can contain. In the case of a PICTURE clause containing all Xs, the USAGE clause determines whether the item is alphanumeric or numeric. Table 5-7 shows the valid contents of both character-string and the item itself for each category. The general rules following this table supplement the information it contains.

    Table 5-7 Summary of PICTURE Clause Rules
    Category of Receiving Item PICTURE of Receiving Item Valid Contents of Sending Item Examples
    Alphabetic Must contain one or more As. One or more alphabetic characters. AA
    A(9)
    Numeric Must contain at least one 9. May contain P's, one S, and one V. If USAGE IS COMP-5 or USAGE IS COMP-X, may contain all Xs. One or more numeric characters. S9(4)V99
    9PPP
    SPP9
    Alphanumeric Must contain combinations of As, Xs, and 9s. Can be all Xs. Cannot be all As or all 9s. One or more characters in computer character set. XX99XX
    AAXA(4)
    Alphanumeric
    Edited
    Must contain at least one A or X. Must also contain at least one B, 0, or /. Can contain one or more 9s. One or more characters in computer character set. XXBXXB9(4)
    XX/99/00
    9(6)/X
    Numeric
    Edited
    Must contain at least one 0, B, /, Z, *, +, (comma), ., --, CR, DB, or cs. Can contain Ps, 9s, and one V. Must describe 1 to 31 digit positions, which can be represented by 9s, zero suppression symbols (Z, *), and floating insertion symbols (+, --, cs). One or more numeric characters. *,***.**
    ZZ,ZZZ/9(4)
    $$,$$$DB
    $9,999CR
    ZZZCR
    **.**

    Note

    COMP-1 and COMP-2 data items are numeric. However, their data description entries cannot have a PICTURE clause.
  2. In an alphanumeric item definition, each character position is treated as if it were represented by an X, even though A or 9 may be specified.
  3. Some PICTURE symbols represent character positions and some do not. An item's size is determined by adding up all the symbols that represent a character position. For example, a numeric item with a PICTURE of 999V99 has a size of five characters. The symbol V does not count toward the item's size.
  4. character-string can contain a repeat count to represent consecutive occurrences of the following symbols: A, the comma (,), X, 9, P, Z, *, B, /, 0, +, --, and the currency symbol (cs). The repeat count must be an unsigned, nonzero integer enclosed in parentheses. For example, S9(6)V9(4) is equivalent to S999999V9999. However, character-string can contain no more than one of the following symbols: S, V, a period (.), CR, and DB.
  5. The PICTURE clause symbols and their functions appear in Table 5-8.

    Table 5-8 PICTURE Clause Symbols
    Picture Clause Symbol Function
    A Represents a character position that can contain only an alphabetic character. An alphabetic character belongs to the set of characters: A to Z, a to z, and the space.
      Can occur more than once.
      Counts toward the size of the item.
    B Represents a character position into which a space is inserted.
      Can occur more than once.
      Counts toward the size of the item.
    N For USAGE IS DISPLAY, represents a character position that can contain any 2-byte character from the national character set. This is available only if /NATIONALITY=JAPAN or -nationality japan is specified.
    P Specifies an assumed decimal scaling position, defining the location of the decimal point when one is not specified in character-string.
      Can occur more than once, but only as a contiguous string of Ps at either the leftmost or rightmost end (not both) of character-string. The assumed decimal point character (V) is redundant when specified. However, when it is specified, V can appear to the left of the leftmost P or to the right of the rightmost P.
      Does not count toward the size of the item. However, each P counts toward the maximum number of digit positions (31) in a numeric or numeric edited item.
      Cannot be used if an explicit decimal point (.) appears in character-string.
      In certain operations that refer to an item with P characters in character-string, the compiler treats each P position as if it contained the value zero. For example, an item with PICTURE 99PPP can have 100 unique values that range from 0 to 99,000 (0, 1000, 2000, ..., 99,000). An item with PICTURE PP9 can have 10 unique values (0, .001, .002, ... .009). These operations are any of the following:
    • Any operation requiring a numeric sending operand
    • A MOVE statement where the sending operand is numeric and its PICTURE character-string contains the symbol P
    • A MOVE statement where the sending operand is numeric edited and its PICTURE character-string contains the symbol P, and the receiving operand is numeric or numeric edited
    • A comparison operation where both operands are numeric
      In all other operations, the compiler ignores the digit positions specified with the symbol P and does not count them toward the size of the operand.
    S Indicates the presence of an operational sign, but does not specify the sign representation or position.
      Can occur only once, as the leftmost character in character-string.
      Does not count toward the size of the item unless the data or screen description entry contains a SIGN IS SEPARATE clause. If the SIGN clause does not appear in the item's data description, S is equivalent to SIGN IS TRAILING.
    V Specifies the location of the assumed decimal point.
      Can occur only once.
      Does not count toward the size of the item.
      Cannot be used if an explicit decimal point (.) appears in the PICTURE.
    X For USAGE IS DISPLAY, represents a character position that can contain any character from the computer character set. For USAGE IS COMP-5 or USAGE IS COMP-X, represents a byte of computer storage.
      Can occur more than once.
      Counts toward the size of the item.
    Z Represents a leading digit position that is replaced by a space when its value and the value of the digits to its left are zero.
      Can occur more than once.
      Counts toward the size of the item.
      Use of Z excludes the use of the asterisk (*) for zero suppression and replacement.
    9 Represents a digit position that can contain only the digits 0 to 9.
      Can occur more than once.
      Counts toward the size of the item.
    0 Represents a character position into which 0 is inserted.
      Can occur more than once.
      Counts toward the size of the item.
    / Represents a character position into which a slash (/) is inserted.
      Can occur more than once.
      Counts toward the size of the item.
    , Represents a character position into which a comma (,) is inserted. +
      Can occur more than once.
      Counts toward the size of the item.
    . Represents a character position into which a decimal point (.) is inserted. It also represents the decimal point for alignment purposes. +
      Can occur only once.
      Counts toward the size of the item.
      Cannot be used if V or P appears in character-string.
    + -- Represents the editing sign control symbols, the plus sign (+) and minus sign (-).
      Each can occur more than once.
      Each counts as one character toward the size of the item.
      character-string can contain either a plus sign (+) or minus (-), but not both. Also, the use of either character excludes the use of both CR and DB.
    CR DB Represents the editing sign control symbols, credit (CR) and debit (DB).
      Each can occur only once, as the two rightmost character positions.
      Each counts as two characters toward the size of the item.
      character-string can contain either CR or DB, but not both. Also, the use of either excludes the use of the plus sign (+) and minus sign (-) as fixed insertion characters.
    * Represents a leading digit position that is replaced by an asterisk (*) when its value and the values of all digit positions to its left are zero.
      Can occur more than once.
      Counts toward the size of the item.
      Use of an asterisk (*) excludes the use of Z for zero suppression and replacement.
    cs Represents a character position into which the currency symbol is inserted. This symbol is either the currency sign ($) or the character specified in the CURRENCY SIGN clause of the SPECIAL-NAMES paragraph or (on OpenVMS) the character specified at DCL command level in the definition of the SYS$CURRENCY logical name.
      Can occur more than once.
      Counts as one character toward the size of the item.

    +When a program contains the DECIMAL POINT IS COMMA clause, the functions and rules for the period (.) and comma (,) are exchanged. In other words, the rules that apply to the period apply to the comma, and vice versa.


Previous Next Contents Index