The most common way to put an index (key) on a file is to define it in the source.
A R ITEMSR
A ICITEM 20 COLHDG(‘Item #’)
A IMANF 8S 0 COLHDG(‘Last Date Sold’)
A K ICITEM
So the 1st 20 characters (the item number) are the key in this example. Note that the UNIQUE keyword is optional – it prevents duplicate keys.
Your source should match your flat file, with the addition of the “K” line(s) of code to define the new key.
Move your flat file to another library.
Compile the source to replace the flat file.
Verify that the file lengths and number of fields match.
CPYF the flat file data into the keyed file (*nochk).