COBOL - 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 replacement symbols in one PICTURE character-string:
Z * + - cs
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.
Representing Zero Suppression:
In a PICTURE character-string, there are two ways to represent zero suppression, and two ways in which editing is performed:
- Any or all of the leading numeric character positions to the left of the decimal point are represented by suppression symbols. When editing is performed, the replacement character replaces any leading zero in the data that appears in the same character position as a suppression symbol. Suppression stops at the leftmost character:
- That does not correspond to a suppression symbol
- That contains nonzero data
- That is the decimal point
- All the numeric character positions in the PICTURE character-string are represented by the suppression symbols. When editing is performed and the value of the data is nonzero, the result is the same as in the preceding rule. If the value of the data is zero, then:
- If Z has been specified, the entire data item will contain spaces.
- If * has been specified, the entire data item except the actual decimal point will contain asterisks.
For example:
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 |
Tips: Do not specify both the asterisk (*) as a suppression symbol and the BLANK WHEN ZERO clause for the same entry.
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!