Here is what I did in the past @Ernie took some time to get the grouping correct, to account for every scenario and when Epicor decides to create a single line vs multiple lines vs multiple releases (all depending on few variables and settings).
// Pass Values to Newly created POs
//
// NOTES:
// Epicor creates a new PO when any of the following changes:
// Grouping Algorithm:
//
// New POHead GroupBy = BuyerID, VendorNum, PurPoint, ShipViaCode, TermsCode, FOB
// New PODtl GroupBy = PartNum, IUM, PUM
// New PORel GroupBy = SugNum processed
//