you can also use Material Group functionality (Basic Data -Tab).Group similar products under one group.Let Say Computer and CD Rom -Under Material Group -100 and Pen- 101 & Shirt 102 and so on.
Put a logic in MV45AFZZ user exit that if sales order line items has different material group then give error or save only when all line items has same material group.
You can also use Item category Group and apply the same logic in sales order user exit at item category level.
or
can also make use of product attributes or Material Group-2 (Sales Org-2- Tab) and put logic in sales order during save to check whether one sales order has all compatible items or not.
Regards
Amit