Skip to main content

Problem:

file error  21( 'Key out of sequence'.) occurs when writing to an indexed file.

Resolution:

Indexed files store their records in key order.  If you attempt to write a record to the file sequentially, and the key of the 'new' record is less than that of the last record in the file, this error will be returned.

Indexed files can be accessed randomly but the key sequence must be borne in mind when writing to them sequentially.

Old KB# 7262

#COBOL
#AcuCobol
#RMCOBOL
#netexpress
#ServerExpress