where iPSPOrder = @order and cBatch = @cBatch and bIsLeafage = 0
) as X
where AddInBomTree.iOrder = @order and cBatch = @cBatch set @Order = (select max(iPSPOrder) from AddInBomTree where iPSPOrder < @order and bIsLeafage = 0 and cBatch = @cBatch )end/*
GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AddinPrcComputeNotLeafageMateCost]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[AddinPrcComputeNotLeafageMateCost]
GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AddinPrcDeletePurchasedItemAndChildrens]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[AddinPrcDeletePurchasedItemAndChildrens]