A user had this error on a payment record, when they were trying to apply a payment:
Dynamics GP Error "The selected document may be damaged. Please rebuild the RM Keys File to correct it "
The standard response is to run check links. However, when we ran the check links against the open transaction table in the test environment, it actually deleted the payment (which was wrong because it had posted to bank, been reconciled and posted to GL as well)
We decided then to manually fix the RM Keys table by running the following query where xxxxxx is the document number.
INSERT INTO RM00401
SELECT DOCNUMBR,RMDTYPAL,2,BCHSOURC,TRXSORCE,CUSTNMBR,CHEKNMBR,DOCDATE,0
FROM RM20101
WHERE DOCNUMBR='xxxxxx'
AND DOCNUMBR NOT IN (select DOCNUMBR from RM00401)
This resolved the issue without deleting a valid document. I was surprised to see that running check links made the issue worse, by removing data from the RM20101 table. In older versions of GP, I was used to seeing the RM_Keys record get added back, based on the actual transaction information.