Define the Key Definition Block

The key definition block has three distinct areas:
  • The Global Information area - this defines the size of the area that contains the key definitions, and the number of keys being defined.
  • The Key Definition area - this defines the characteristics of each key in the block.
  • The Component Definition area - this defines the details of each component within each key defined in the previous area.
  1. Beneath the filename area definition, paste the following code:
           01 ex-keydef.                               
              47 key2length                pic 9(4)  comp-x.
              47 key-version               pic 9(2) comp-x value 2. 
              47 filler                    pic 9(6)  comp-x. *> reserved
              47 key-count                 pic 9(4)  comp-x.
              47 filler                    pic 9(13) comp-x. *> reserved
  2. Next you need to paste the following key definition area:
          *  key-specification is repeated for the number of keys defined by
          *  key-count
              47 key-specification. 
                 49 component-count        pic 9(4) comp-x.
          * The offset for the component-specification for this key
                 49 component-defs         pic 9(4) comp-x. 
                 49 key-flags              pic 9(2) comp-x.
                      78 KEY2KEYFLAG-DUPS-IN-ORDER        value h"40".
                      78 KEY2KEYFLAG-PRIME                value h"10".
                      78 KEY2KEYFLAG-SPARSE-KEY           value h"02".
                 49 key-compression        pic 9(2) comp-x.
                      78 KEY2COMPRESS-TRAILING-NULLS      value h"08".
                      78 KEY2COMPRESS-TRAILING-SPACES     value h"04".
                      78 KEY2COMPRESS-IDENTICAL-CHARS     value h"02".
                      78 KEY2COMPRESS-FOLLOWING-DUP       value h"01".
                      78 KEY2COMPRESS-NO-COMPRESSION      value h"00".
                      78 KEY2COMPRESS-DEFAULT        value KEY2COMPRESS-NO-COMPRESSION.
                 49 sparse-characters      pic x(2).
                 49 filler                 pic x(8). *> reserved
  3. Finally, you need to paste the component definition area to complete the key definition block:
          *  component-specifications for all keys follows after the key-specifications
          *  for all the keys.
              47 component-specification.
                 49 component-flags        pic 9(2) comp-x.
                 49 component-type         pic 9(2) comp-x.  
                      78 KEY2PARTTYP-NUMERIC              value h"80".
                      78 KEY2PARTTYP-SIGNED               value h"40".
                      78 KEY2PARTTYP-COMP                 value h"20".
                      78 KEY2PARTTYP-COMP-3               value h"21".
                      78 KEY2PARTTYP-COMP-X               value h"22".
                      78 KEY2PARTTYP-COMP-5               value h"23".
                      78 KEY2PARTTYP-FLOAT                value h"24".
                      78 KEY2PARTTYP-COMP-6               value h"25".
                      78 KEY2PARTTYP-DISPLAY              value h"00".
                      78 KEY2PARTTYP-SIGN-TRAIL-INCL      value h"00".
                      78 KEY2PARTTYP-SIGN-TRAIL-SEP       value h"01".
                      78 KEY2PARTTYP-SIGN-LEAD-INCL       value h"02".
                      78 KEY2PARTTYP-SIGN-LEAD-SEP        value h"03".
                      78 KEY2PARTTYP-SIGN-LEAD-FLOAT      value h"04".
                 49 component-offset       pic 9(9) comp-x.
                 49 component-length       pic 9(9) comp-x.

Later in the tutorial, a set-keydefinitions section is added that populates the values in this block.

Finally, you need to define a group for the records that will be written to and read from the data file.