alter PROCEDURE cpinstock
(@FBillNO varchar(255),@FName varchar(255),@FQty decimal(28, 10),@FEntryID int, @insert int out)
as
begin
---判断条件:生产任务单必须是下达状态,未完全入库
if exists(
select 1 from icmo a
inner join t_icitem b on a.FItemID = b.FitemID
where substring(FBillNo,0,charindex('*',FBillNo)) = @FBillNO
and b.FName = @FName
and a.FSourceEntryID = @FEntryID
and (FQty-FCommitQty) < @FQty
)
begin
--返回错误提示
-- RAISERROR('错误:已入库!',16,1)
--不允许插入,更新变量为0,返回变量
set @insert = 0
end
else
begin
declare @FInterID_1 int
exec GetICMaxNum 'icstockbill',@FInterID_1 output,1
-- select @FInterID_1
declare @FMaxCINint int
select @FMaxCINint = cast(substring(FBillNo,4,6) as int) from icstockbill
where FTranType = 2
and FinterID in (select Max(FinterID) from icstockbill where FTranType = 2)
----插入产品入库单据头表