日期:2014-05-18 浏览次数:20591 次
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[zzz_Cz_BOM] @Fnumber nvarchar(255) AS declare @finterid int declare @fitemid int select @fitemid=fitemid from t_icitem where --fnumber='01.HY.HY-1/116-B-S' fnumber=@fnumber select @finterid=finterid from icbom where fitemid=@fitemid -- and fusestatus=1072 Create Table #Errorss ( FIndex int IDENTITY, FType smallint default(0), FBomNumber int default(0), FErrText nvarchar(355) ) Create Table #data1 ( FIndex int IDENTITY, FBomInterid int, FItemID int null, FNeedQty decimal(28,8) default(0) null, FBOMLevel int null, FItemType int null, FParentID int default(0)null, FRate decimal(20,8) default(0) null, FHistory int default(0) null, FHaveMrp smallint default(0) null, FLevelString nvarchar(200) null, FBom int ) exec PlanBomNestingCheck @finterid /* select a.FBomnumber FNumber ,b.FNumber FItemNumber,b.FName ,b.FModel,c.FBOMLevel from icbom a,t_icitem b ,#data1 c where a.finterid=c.FBomInterid and b.fitemid =a.fitemid and c.FBOMLevel=0 */ Create Table #Mutidata ( FIndex int IDENTITY, FEntryID INT, FBomInterid int, FItemID int null, FNeedQty decimal(28,14) default(0) null, FBOMLevel int null, FItemType int null, FParentID int default(0)null, FRate decimal(28,14) default(0) null, FHistory int default(0) null, FHaveMrp smallint default(0) null, FLevelString varchar(200) null, FBom int, FMaterielType int default(371) null, FOperID int default(0)) Create Table #MutiParentItem (FIndex int IDENTITY, FEntryID INT default(0), FBomInterid int, FItemID int null, FNeedQty decimal(28,14) default(0) null, FBOMLevel int null, FItemType int null, FParentID int default(0)null, FRate decimal(28,14) default(0) null, FHistory int default(0) null, FHaveMrp smallint default(0) null, FLevelString varchar(200) null , FBom int, FMaterielType int default(371) null, FOperID int default(0), froutingid int null, fnumber int ) Create Table #Errors ( FIndex int IDENTITY, FType smallint default(0), FErrText varchar(355) ) Insert into #mutiParentItem (fbominterid,FItemID,FNeedQty,FBOMLevel,FParentID,FItemType,FBom,froutingid) Select a.finterid, t1.FItemID,a.fqty, 0,0,t1.FErpClsID,t1.FItemID, a.FRoutingid From icbom a,t_ICItem t1 Where t1.FItemID = a.fitemid and a.finterid=@finterid declare @P1 int set @P1=0 declare @P2 char(400) set @P2='