Example of Creating Variable Length Records

 file control.
     select fd-name
         assign to "user.dat"
         organization is indexed
         access mode is dynamic
         record key is fd-name-key.
 file section.
 fd fd-name.
    record is varying in size
     from 5 to 80 characters depending on ws-record-count.
 01 fd-name-record.
     05 fd-name-key    pic x(5).
     05 fd-name-data   pic x(75).
 working-storage section.
 01 ws-record-count    pic 99 comp-x.

In this example an indexed file with variable-length records, varying in length from 5 to 80 bytes, is defined. Note that any key(s) must lie within the fixed part of the record.