Returns a bit string of length 1 indicating whether a record x that has been accessed is followed by another one with the same key.
The SAMEKEY function returns a bit string of length 1 indicating whether a record that has been accessed is followed by another with the same key. If it is followed by such record, the value returned is '1'B. The value is set to '0'B if the processed record is not followed by another one with the same key, if the file is not open, if no current cursor position exists in the file or if an input/output operation that raises a condition other than RECORD also causes file positioning to be changed or lost.
foo: procedure options(main); dcl db2 file env(vsam keyloc(5) keylength(4) recsize(80) reuse); dcl 1 db_record, 2 dbkey char(4), 2 dbaix char(4), 2 filler char(72); open file(db2); read file(db2) into(db_record) key('KEY1'); if samekey(db2) then put skip list("next record is duplicate key"); close file(db2); end foo;