I think you should simply use a field in the material document (header) which uniquely identifies the external document (GR) which is to be replicated in SAP.
If you have this unique id in the material document (header) then you can use an enhancement in the idoc processing function module to perform a check - if there's a material document in SAP with that unique id than the IDOC processing should fail (because you don't want to post the same GR again).