To define the primary key of an indexed file use the RECORD KEY IS clause in the SELECT clause:
select idxfile assign to "idx.dat" organization is indexed record key is idxfile-record-key.