ILE COBOL Language Reference

PICTURE Clause Editing

There are two general methods of editing in a PICTURE clause:

The type of editing allowed for an item depends on its data category. The type of editing that is valid for each category is shown below:

Table 15. Valid Editing for Each Data Category

Category Type of Editing
Alphabetic None

+-------------------------------IBM Extension--------------------------------+

Boolean

+----------------------------End of IBM Extension----------------------------+

None

+-------------------------------IBM Extension--------------------------------+

DBCS

+----------------------------End of IBM Extension----------------------------+

None

+-------------------------------IBM Extension--------------------------------+

National

+----------------------------End of IBM Extension----------------------------+

None

+-------------------------------IBM Extension--------------------------------+

DBCS-edited

+----------------------------End of IBM Extension----------------------------+

Simple insertion
Numeric None
Alphanumeric None
Alphanumeric edited Simple insertion
Numeric edited All

+-------------------------------IBM Extension--------------------------------+

External floating-point

+----------------------------End of IBM Extension----------------------------+

Special insertion

Simple Insertion Editing

This type of editing is valid for numeric-edited, and alphanumeric-edited items.

+-------------------------------IBM Extension--------------------------------+

This type of editing is valid for DBCS-edited items.

+----------------------------End of IBM Extension----------------------------+

Each insertion symbol is counted in the size of the item, and represents the position within the item where the equivalent characters will be inserted.

Table 16. Simple Insertion Editing - Valid Insertion Symbols for Each Data Category

Category Valid Insertion Symbols
Alphabetic None

+-------------------------------IBM Extension--------------------------------+

Boolean

+----------------------------End of IBM Extension----------------------------+

None

+-------------------------------IBM Extension--------------------------------+

DBCS

+----------------------------End of IBM Extension----------------------------+

None

+-------------------------------IBM Extension--------------------------------+

National

+----------------------------End of IBM Extension----------------------------+

None

+-------------------------------IBM Extension--------------------------------+

DBCS-edited

+----------------------------End of IBM Extension----------------------------+

B
Numeric None
Alphanumeric None
Alphanumeric edited B 0 / - . , &
Numeric edited B 0 / ,

Examples of simple insertion editing:

PICTURE          Value of Data      Edited Results
X(10)/XX         ALPHANUMER01       ALPHANUMER/01
X(5)BX(7)        ALPHANUMERIC       ALPHA NUMERIC
99,B999,B000     1234               01, 234, 000
99,999           12345              12,345
GGBBGG           D1D2D3D4           D1D2    D3D4

Special Insertion Editing

This type of editing is valid only for:

The period (.) is the special insertion symbol; it also represents the actual decimal point for alignment purposes.

The period insertion symbol is counted in the size of the item, and represents the position within the item where the actual decimal point is inserted.

Either the actual decimal point or the symbol V as the assumed decimal point, but not both, must be specified in one PICTURE character-string.

Examples of special insertion editing:

PICTURE          Value of Data      Edited Results
999.99              1.234           001.23
999.99             12.34            012.34
999.99            123.45            123.45
999.99           1234.5             234.50
+999.99E+99     12345               +123.45E+02

Fixed Insertion Editing

This type of editing is valid only for numeric-edited items. The following insertion symbols are used:

In fixed insertion editing, only one currency symbol and one editing-sign control symbol can be specified in one PICTURE character-string.

The currency symbol represents the position at which a currency sign is to appear. A currency sign may be the currency symbol itself, or a currency-string one or more characters in length that is specified in the CURRENCY SIGN clause of the SPECIAL-NAMES paragraph. The size of the edited item will be increased by the number of characters contained in the corresponding currency-string.

Unless it is preceded by a + or - symbol, the currency symbol must be the first character in the character-string.

When either + or - is used as a symbol, it must be the first or last character in the character-string.

When CR or DB is used as a symbol, it must occupy the rightmost two character positions in the character-string. If these two character positions contain the symbols CR or DB, the uppercase letters are the insertion characters.

Editing sign control symbols produce results that depend on the value of the data item, as shown below:

Editing Symbol       Result:              Result:
in PICTURE           Data Item            Data Item
Character-String     Positive or Zero     Negative
+                    +                    -
-                    space                -
CR                   2 spaces             CR
DB                   2 spaces             DB

Examples of fixed insertion editing:

   PICTURE         Value of Data    Edited Result
    999.99+         +6555.556        555.55+
  +9999.99          -6555.555      -6555.55
   9999.99          +1234.56        1234.56
   $999.99           -123.45        $123.45
   U999.99           -123.45      EUR123.45 (1)
  -$999.99           -123.456      -$123.45
  -u999.99           -123.456    -USD123.45 (2)
  -$999.99           +123.456       $123.45
  $9999.99CR         +123.45       $0123.45
  $9999.99DB         -123.45       $0123.45DB

(1)
For a currency sign defined as: CURRENCY SIGN IS "EUR" PICTURE SYMBOL "U"

(2)
For a currency sign defined as: CURRENCY SIGN IS "USD" PICTURE SYMBOL "u"
Note:
Beware of situations where sign truncation would lead to negative amounts being shown as credits.

Floating Insertion Editing

This type of editing is valid only for numeric-edited items. The following symbols are used:

Within one PICTURE character-string, these symbols are mutually exclusive as floating insertion symbols.

Floating insertion editing is specified by including two or more consecutive floating insertion symbols in the PICTURE character-string.

A currency symbol represents a currency sign, which may either be the currency symbol itself, or a currency-string one or more characters in length that is specified in the CURRENCY SIGN clause of the SPECIAL-NAMES paragraph. The size of the edited item will be increased by the number of characters contained in the corresponding currency-string for the first currency symbol present, and by a further character for each additional currency symbol in the PICTURE character-string.

If the floating insertion symbol represents a single character, the symbols are used to represent all character positions into which the corresponding character could be inserted. The leftmost floating insertion symbol in the character-string represents the leftmost limit at which the character can appear in the data item. The rightmost floating insertion symbol represents the rightmost limit at which the character can appear.

If the floating insertion symbol represents a multiple-character currency-string, the symbols are used to represent all the positions into which the final character of the currency-string could be inserted. The leftmost floating insertion symbol in the character-string represents the leftmost limit at which the final character of the currency-string can appear in the data item. The rightmost floating insertion symbol represents the rightmost limit at which the final character of the currency-string can appear.

The second leftmost floating insertion symbol in the character-string represents the leftmost limit at which numeric data can appear within the data item. Floating insertion symbols at or to the right of this limit represent numeric character positions. They may be replaced by numeric data, starting with the leading nonzero numeric character.

Any simple-insertion symbols (B 0 / ,) within or to the immediate right of the string of floating insertion symbols are considered part of the floating character-string. If the period (.) special-insertion symbol is included within the floating string, it is considered to be part of the character-string.

In a PICTURE character-string, there are two ways to represent floating insertion editing and thus, two ways in which editing is performed:

  1. Any or all leading numeric character positions to the left of the decimal point are represented by the floating insertion symbol. When editing is performed, a single floating sign insertion symbol (+ or -), or the currency sign, is placed to the immediate left of the first nonzero digit in the data, or of the decimal point, whichever is farther to the left. Any unused positions to the left of the insertion symbol or currency sign are filled with spaces.
  2. All the numeric character positions are represented by the floating insertion symbol. When editing is performed, then:

To avoid truncation, the minimum size of the PICTURE character-string must be:

Examples of floating insertion editing:

   PICTURE               Value of Data        Edited Result
        $$$$.99                 .123               $.12
        $$$9.99                 .12               $0.12
   $,$$$,999.99            -1234.56           $1,234.56
   U,UUU,UU9.99-           -1234.56         EUR1,234.56-
   u,uuu,uu9.99             1234.56         USD1,234.56
   +,+++,999.99          -123456.789        -123,456.78
  $$,$$$,$$$.99CR       -1234567          $1,234,567.00CR
  ++,+++,+++.+++            0000.00
Note:
Beware of situations where sign truncation would lead to negative amounts being shown as credits.

Zero Suppression and Replacement Editing

This type of editing is valid only for numeric-edited items.

In zero suppression editing, the symbols Z and * are used. These symbols are mutually exclusive in one PICTURE character-string.

The following symbols are mutually exclusive as floating symbols within one PICTURE character-string:

   Z  *  +  -  Currency symbol (for example, $)

Specify zero suppression and replacement editing with a string of one or more of the allowable symbols to represent leftmost character positions in which zero suppression and replacement editing can be performed.

Any simple insertion symbols (B 0 / ,) within or to the immediate right of the string of floating editing symbols are considered part of the string. If the period (.) special insertion symbol is included within the floating editing string, it is considered to be part of the character-string.

In a PICTURE character-string, there are two ways to represent zero suppression, and two ways in which editing is performed:

Note:
Do not specify both the asterisk (*) as a suppression symbol and the BLANK WHEN ZERO clause for the same entry.

Examples of zero suppression and replacement editing:

   PICTURE               Value of Data       Edited Result
           ****.**           0000.00               ****.**
           ZZZZ.ZZ           0000.00
           ZZZZ.99           0000.00                   .00
           ****.99           0000.00               ****.00
           ZZ99.99           0000.00                 00.00
          Z,ZZZ.ZZ+          +123.456               123.45+
          *,***.**+          -123.45              **123.45-
     **,***,***.**       +12345678.9         12,345,678.90+
     $Z,ZZZ,ZZZ.ZZCR       +12345.67         $   12,345.67
    $B*,***,***.**BBDB     -12345.67        $ ***12,345.67  DB 


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]