Sometimes it is necessary to specify the printing of numeric data items using different editing rules from those supplied by the Reporting Facility. If this is the case, supply a PICTURE clause on the DEFINE command used to define the numeric item. The PICTURE clause is valid only on the DEFINE command and restricts edit pattern specification to explicitly defined fields.
Implicitly defined numeric fields always print using the default printing techniques discussed in the previous section. The edit mask in the PICTURE clause is specified as an alphanumeric literal enclosed in apostrophes, and the field must be defined as either N (zoned decimal) or P (packed decimal).
COBOL-like edit patterns can be coded, although some restrictions apply. The following editing features are supported:
Each edit pattern must be composed of specific characters so the type of editing to be performed can be determined. Valid characters in an edit pattern are described as follows:
Specifies a numeric digit position that is always replaced by the corresponding digit from the source field, with no zero suppression implied.
Specifies a numeric digit position that is replaced by a digit from the source field if a significant source digit (nonzero) is encountered; otherwise, the position is set to a blank (X'40').
Specifies a numeric field position that is replaced by a digit from the source field if a significant source digit is encountered; otherwise, the position is set to an asterisk (X'5C'). This gives the ability to "asterisk protect" leading nonsignificant digits in a printed field.

Specifies a numeric digit position that is replaced by a digit from the source field if a significant source digit is encountered. Leading, nonsignificant positions are set to blank and the dollar sign or euro currency symbol is printed to the left of the first significant digit. This enables you to "float" the currency symbol with a printed field.
You can also specify the currency symbol as the first character in the edit pattern, along with other "replacement" characters. This causes a single currency symbol to print in a fixed location. Then normal editing continues.
Note: To change from a dollar sign to a euro currency symbol, specify the hex code 9F in the PICTURE clause.
Specifies that a plus sign is to be printed when the numeric item being edited is positive. When the numeric item is negative, a blank prints. You must code this as the rightmost character in the edit pattern.
Specifies that a minus sign is to be printed when the numeric item being edited is negative. When the numeric item is positive, a blank prints. A minus sign, or dash, can also be used as a separator. (An example is a social security number.)
Performs like the plus sign, with the exception that DB is printed in the two rightmost positions when the numeric item is positive.
Performs like the minus sign, with the exception that CR is printed in the two rightmost positions when the numeric item is negative.
Specifies that a decimal point is to print in the corresponding print position. Only one decimal point is allowed in a single edit pattern.
Specifies that a comma is to be printed in the corresponding print position. Any number of commas can be coded in a single edit pattern.
Specifies that a slash is to be printed in the corresponding print position. Any number of slashes can be coded in a single edit pattern.
The following table illustrates some practical uses of the edit pattern specification:
EDIT PATTERN VALUE/PRECISION EDITED RESULT
PIC 'ZZZZ9.99999' 0000012345 (5.5) 0.12345
PIC '$$,$$9.99-' 1234567 (5.2) $12,345.67
PIC '$**,***.**' 0034567 (5.2) $**,345.67
PIC '999' 123 (3.0) 123
PIC '999-' 123-(2.1) 123-
PIC 'Z9' 03406 (3.2) 6
PIC '999' 000 (3.0) 000
PIC 'ZZZ' 000 (3.0) blank
PIC '$$$9.99CR' 12345-(3.2) $123.45CR
PIC '$$$9.99DB' 12345 (3.2) $123.45DB
PIC 'ZZZZZ9' 00123-(4.1) 123
PICTURE '999CR' 123 (3.0) 123
PICTURE 'ZZZZ9' 00000 (1.4) 0
Note the following:
|
Copyright © 2014 CA.
All rights reserved.
|
|