The RMAR is nothing but PO number. It coming from the below code:
It is extracting VBAK table for the PO number. Once one record is processed, it has to be cleared and need to check for the other record. In this case RMAR is not cleared, hence it is showing the same PO number in RMAR field. It is fetching based on the sales order number. If the sales order is not there, it will return blank value. In case sales order is not there , it need to look into the (LIPS table) delivery note and need to pick the PO number, then this problem will be avoided. This query need to be changed accordingly.
See the below screen shot for linking the delivery note with PO number