Credit memo is "money only" transaction, e.g. a price adjustment. This usually does not involve any goods movement. Are you sure you are not talking about the return process?
501 is goods receipt without purchase order, I'm really not sure what does it have to do with a credit memo...
You might want to clarify what is the business process and what is the specific ABAP issue here.