The following program turns on key compression in a file by setting the appropriate bits in the file's Key Definition Block.
$set fcdreg select masterfile assign to ... organization is indexed record key is rec-key alternate key is m-alt-key-1 with duplicates alternate key is m-alt-key-2 alternate key is m-alt-key-3 with duplicates. select indexfile assign to ... organization is indexed record key is rec-key alternate key is t-alt-key-1 with duplicates. ... working-storage section. ... linkage section. 01 key-def-block. 03 filler pic x(6). 03 key-count pic 9(4) comp-x. 03 filler pic x(6). 03 key-def occurs 1 to 4 times depending on key-count. 05 filler pic x(5). 05 key-compression pic 9(2) comp-x. 05 filler pic x(10). ... procedure division. set address of key-def-block to address of fh--keydef of masterfile move 6 to key-compression (1) move 7 to key-compression (2) move 6 to key-compression (3) move 7 to key-compression (4) open I-O masterfile ... set address of key-def-block to address of fh--keydef of indexfile move 4 to key-compression (1) move 1 to key-compression (2) open input indexfile