标签:save condition mod join tle pst tac fbi eid
USE [AIS20161026095136]
GO
/****** Object: StoredProcedure [dbo].[x_xlh1] Script Date: 2017/1/23 13:18:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[x_xlh1]
@rkwl varchar(50),@rksl int,@ckwl varchar(50), @cksl int,@fbillno varchar(50)
AS
BEGIN
declare @FInterid2 int
declare @FInterid1 int
declare @fcustid int
DECLARE @fdcstockid int
declare @fbase2 varchar(50)
declare @fbaseproperty varchar(50)
declare @fbaseproperty2 varchar(50)
declare @finteger int
declare @fentryid int
declare @fitemid int
declare @fid int
declare @Fbillno1 varchar(50)
declare @Fbillno2 varchar(50)
declare @FbillnoBM varchar(50)
declare @fdcstockid1 int
declare @FUnitIDICItem int
declare @fbillnolen int
declare @fbiller int
declare @fitemid1 int
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
select 1
select top 1 @fcustid=a1.fbase5 from t_bos200000001entry2 a1 inner join t_bos200000001 b1 on a1.fid=b1.fid where b1.fbillno=@fbillno
select @fbiller=fbiller from t_bos200000001 where fbillno=@fbillno
-- 出库单单据编号
select @FbillnoBM =FProjectVal from t_BillCodeRule where FBilltypeID=‘29‘ and FProjectID=1
select @fbillnolen=Flength,@Fbillno1=FProjectVal from t_BillCodeRule where FBilltypeID=‘29‘ and FProjectID=3
select @Fbillno1 = @FbillnoBM + Right(‘000000‘+ @Fbillno1, @FbillnoLen)
--出库单主键
exec GetICMaxNum ‘ICStockbill‘,@FInterid2 output ,29,16394
-- 入库单单据编号
select @FbillnoBM =FProjectVal from t_BillCodeRule where FBilltypeID=‘10‘ and FProjectID=1
select @fbillnolen=Flength,@Fbillno2=FProjectVal from t_BillCodeRule where FBilltypeID=‘10‘ and FProjectID=3
select @Fbillno2 = @FbillnoBM + Right(‘000000‘+ @Fbillno2, @FbillnoLen)
select @fid=fid from t_bos200000001 where fbillno=@fbillno
--回收仓002
select @fdcstockid1=891
select * from t_stock
--入库单主键
exec GetICMaxNum ‘ICStockbill‘,@FInterid1 output ,10,16394
select @fitemid=fitemid from t_icitem where FNumber=@rkwl
select @FUnitIDICItem=funitid from t_ICItem where FItemID=@fitemid
--发货仓001
select @fdcstockid=fbase from t_BOS200000001Entry2 a1 inner join t_BOS200000001 b1 on a1.fid=b1.fid
where b1.FBillNo=@fbillno and a1.fbase5=@fitemid
--生成入库单
insert into ICStockBillEntry (FBrNo,FInterID,FEntryID,FItemID,FQtyMust,FQty,FPrice,
FBatchNo,FAmount,FNote,FAuxPrice,FAuxQty,FAuxQtyMust,
FSourceEntryID,FSourceTranType,FSourceInterId,FSourceBillNo,
FICMOInterID,FPPBomEntryID,FOrderInterID,FOrderEntryID,
FOrderBillNo,FDCStockID,FPlanMode,FFatherProductID,FICMOBillNo,FUnitID)
values (‘0‘,@FInterid1,1,@fitemid,@rksl,@rksl ,0,
0,0,‘‘,0,@rksl ,@rksl,
0,‘1007105‘,@fid,@Fbillno,
@fid,1,@FInterid2,1,
@Fbillno,@fdcstockid1,‘14036‘,@fitemid,@Fbillno,@FUnitIDICItem )
insert into ICStockBill (FBrNo,FInterID,FTranType,FDate,FBillNo,FNote,
FSupplyID,FFManagerID,FSManagerID,FBillerID,
FROB,FUpStockWhenSave,FOperDate,FMarketingStyle,
FSelTranType,FsourceType,
FPurposeID,FCussentAcctID,FPayCondition
,FSettleDate,FDCStockID ,FCheckerID,fstatus,fcheckdate)
values (‘0‘,@FInterid1,‘10‘,convert(varchar(10),getdate(),120),@Fbillno2,‘‘,
@fcustid,‘‘,‘‘,@fbiller,
‘1‘,‘1‘,null,‘12530‘,
‘‘,‘37521‘
,14190,1104,1000
,convert(varchar(10),getdate(),120),@fdcstockid1,16393,1,convert(varchar(10),getdate(),120))
--更新库存
update ICInventory set fqty=fqty+@rksl where fitemid=@fitemid and FStockID=@fdcstockid1
update t_BillCodeRule set FProjectVal=(select Fprojectval from t_BillCodeRule Where FBillTypeID = ‘10‘ and FProjectID=3)+1 Where FBillTypeID = ‘10‘ and FProjectID=3
select @fitemid1=fitemid from t_icitem where FNumber=@ckwl
select @FUnitIDICItem=funitid from t_ICItem where FItemID=@fitemid1
--生成出库单
insert into ICStockBillEntry (FBrNo,FInterID,FEntryID,FItemID,FQtyMust,FQty,FPrice,
FBatchNo,FAmount,FNote,FAuxPrice,FAuxQty,FAuxQtyMust,
FSourceEntryID,FSourceTranType,FSourceInterId,FSourceBillNo,
FICMOInterID,FPPBomEntryID,FOrderInterID,FOrderEntryID,
FOrderBillNo,FDCStockID,FPlanMode,FFatherProductID,FICMOBillNo,FUnitID)
values (‘0‘,@FInterid2,1,@fitemid1,@cksl,@cksl ,0,
0,0,‘‘,0,@cksl ,@cksl,
0,‘1007105‘,@fid,@Fbillno,
@fid,1,@FInterid2,1,
@Fbillno,@fdcstockid,‘14036‘,@fitemid1,@Fbillno,@FUnitIDICItem )
insert into ICStockBill (FBrNo,FInterID,FTranType,FDate,FBillNo,FNote,
FSupplyID,FFManagerID,FSManagerID,FBillerID,
FROB,FUpStockWhenSave,FOperDate,FMarketingStyle,
FSelTranType,FsourceType,
FPurposeID,FCussentAcctID,FPayCondition
,FSettleDate,FDCStockID,FCheckerID,fstatus,fcheckdate )
values (‘0‘,@FInterid2,‘29‘,convert(varchar(10),getdate(),120),@Fbillno1,‘‘,
@fcustid,‘‘,‘‘,@fbiller,
‘1‘,‘1‘,null,‘12530‘,
‘‘,‘37521‘
,14190,1104,1000
,convert(varchar(10),getdate(),120),@fdcstockid,16393,1,convert(varchar(10),getdate(),120) )
--更新库存
update ICInventory set fqty=fqty-@cksl where fitemid=@fitemid1 and FStockID=@fdcstockid
update t_BillCodeRule set FProjectVal=(select Fprojectval from t_BillCodeRule Where FBillTypeID = ‘29‘ and FProjectID=3)+1 Where FBillTypeID = ‘29‘ and FProjectID=3
END
标签:save condition mod join tle pst tac fbi eid
原文地址:http://www.cnblogs.com/xujiating/p/6343874.html