Boolean data is either TRUE or FALSE. These are data types
are useful for flags for so-called condition-name conditions .
A simple example:
A D V E R T I S E M E N T
000100 IDENTIFICATION DIVISION.
000110 PROGRAM-ID. NUMBER-SIZE-PROG.
000120 AUTHOR. TRP BROWN.
000140 DATA DIVISION.
000150 WORKING-STORAGE SECTION.
000160 01 NUMBER-SIZE PIC X.
000170 88 BIG-NUMBER VALUE 'Y'.
000190 77 DATA-NUMBER PIC 9(6).
000220 PROCEDURE DIVISION.
000240 MOVE 'N' TO NUMBER-SIZE
000250 ACCEPT DATA-NUMBER
000260 IF DATA-NUMBER > 1000
000270 THEN MOVE 'Y' TO NUMBER-SIZE
000290 IF BIG-NUMBER
000300 THEN DISPLAY 'Thats a big number'
000310 ELSE DISPLAY 'Thats a little number'
000330 STOP RUN.
When then number entered (line 250) is greater than 1000 then a 'Y'
character is moved to the level 01 item NUMBER-SIZE. The effect of this
is to give the level 88 item BIG-NUMBER a TRUE condition. This is what
level 88 is for in COBOL.
Line 240 initially sets BIG-NUMBER to false by moving an 'N'
character into NUMBER-SIZE, although any character (other than 'Y')
would have the same effect.
IF BIG-NUMBER THEN... is like saying "IF BIG-NUMBER is true THEN..."
Multiple level 88 can be set for a single group, or
you can have more than one option that will set the condition to true.
01 THIRTY-DAY-MONTHS PIC X VALUE SPACE.
88 SEPTEMBER VALUE 'S'.
88 APRIL VALUE 'A'.
88 JUNE VALUE 'J'.
88 NOVEMBER VALUE 'N'.
01 MONTHS-CHECK PIC X.
88 SHORT-MONTH VALUE 'S' 'A'
01 GRADES-CHECK PIC 999.
88 A-GRADE VALUE 70 THRU 100.
88 B-GRADE VALUE 60 THRU 69.
88 C-GRADE VALUE 50 THRU 59.
88 FAIL-GRADE VALUE 0 THRU 49.
GRADES-CHECK uses THRU (or THROUGH) to allow a range of numeric values to be
A useful verb to use is SET. Rather than having
to use the line: MOVE 'Y' TO NUMBER-SIZE
as in the code example above, you can simply set the boolean variable to
true by coding: SET BIG-NUMBER TO TRUE
This means that you don't have to worry about what the value of the level 01
item has to be in order to make the associated level 88 to be true (notice
that it is the level 88 item name that is set to true and NOT the level 01
item). However, you are not allowed (with Fujitsu COBOL85 anyway) to code
SET BIG-NUMBER TO FALSE.
Instead you'll have to use the normal: MOVE 'N' TO BIG-NUMBER.