Customer and Supplier

@Naqvi in your examples:
ABC is a customer 1000 in 1 and a supplier 4000 in 2
LMN is a supplier 800 in 1 and a customer 5000 in 2.

So both entities are simultaneously a customer and supplier.

These are separate ABC/LMN customer and ABC/LMN supplier transactions, and are not mergeable to a single customer/suppler account at the transaction level. To contra the balances between a ABC customer and a ABC supplier then use a General Journal as per the referred to Guide.