Hi..
If you activate material ledger and don’t apply note “SAP Note167722 - Transfer posting material to material is single-level proces.”this situation which you mentioned above will not be occurred.
The difference US20 between material A and B will be recognized as COSG.