BLANK WHEN ZERO Clause
BLANK WHEN ZERO Clause
- BLANK WHEN ZERO clause makes a variable display the SPACES when its value is ZERO.
- It should code with a numeric or numeric-edited variable.
- This clause is used only on elementary variables and is coded anywhere in Area B but not in Area A.
Syntax -
Note! All statements coded in [ ] are optional.
Rules to Remember -
- Elementary variables should be declared USAGE as DISPLAY.
- Numeric-edited items declared with BLANK WHEN ZERO shouldn't be used in arithmetic operations (ADD, SUBTRACT, MULTIPLY, DIVIDE, and COMPUTE).
- BLANK WHEN ZERO clause should not code with level-66 and level-88.
- BLANK WHEN ZERO clause should not code with the variables declared with S or *.
Practical Example -
Scenario - Explaining how the BLANK WHEN ZERO is used in COBOL programming.
Code -
----+----1----+----2----+----3----+----4----+----5----+
...
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-VAR.
05 WS-NED-VAR PIC ZZ,ZZ9.9(2).
* Declaring a variable with BLANK WHEN ZERO
05 WS-BWZ-VAR PIC ZZ,ZZ9.9(2) BLANK WHEN ZEROES.
...
PROCEDURE DIVISION.
MOVE ZEROES TO WS-NED-VAR
WS-BWZ-VAR.
DISPLAY "WS-NED-VAR: " WS-NED-VAR.
DISPLAY "WS-BWZ-VAR: " WS-BWZ-VAR.
DISPLAY " ".
...
Output -
WS-NED-VAR: 0.00 WS-BWZ-VAR: