Display Computation
Display Computation
- DISPLAY computation is the most used internal data representation.
- It uses the character form, in which one character equals one byte (8 bits) of storage.
- If no usage clause is used, then DISPLAY usage will be applied by default.
DISPLAY computation applies to the following data types -
- Alphabetic
- Alpha-numeric
- Numeric
Below table represents the storage occupied based on the number of digits in PICTURE clause –
PICTURE clause | Storage occupied |
---|---|
1 Digit | Char | 1 byte |
Practical Example -
Scenario - Describes how DISPLAY computation is used in COBOL programming.
Code -
----+----1----+----2----+----3----+----4----+----5----+
...
WORKING-STORAGE SECTION.
01 WS-VAR.
05 WS-VAR1 PIC 9(06) USAGE DISPLAY.
05 WS-VAR2 PIC 9(06).
...
PROCEDURE DIVISION.
DISPLAY "WS-VAR1 (DISPLAY COMPUTATION) LENGTH IS: "
LENGTH OF WS-VAR1.
DISPLAY "WS-VAR2 LENGTH IS: " LENGTH OF WS-VAR2.
...
Output -
WS-VAR1 (DISPLAY COMPUTATION) LENGTH IS: 000000006 WS-VAR2 LENGTH IS: 000000006