SAP B1 9.1 生产收货数量加已完成数量不能大于计划数量(存储过程控制代码)
--生产收货,收货数量加已完成数量不能大于计划数量。注:OWOR中的CmpltQty实际为输入的收货数量加上原来的完成数量 if(@object_type='59') begin IF @transaction_type IN('A','U') begin declare @itemcode varchar(20) declare @BaseRef varchar(20) declare @Quantity numeric(19,6) declare @recnum numeric(19,6) DECLARE YOUCURNAME CURSOR FOR SELECT T1.BaseRef,T1.ItemCode,ISNULL(T1.Quantity,0) from OIGN T0 INNER JOIN IGN1 T1 ON T0.DocEntry = T1.DocEntry WHERE T1.DocEntry=@list_of_cols_val_tab_del OPEN YOUCURNAME fetch next from YOUCURNAME into @BaseRef,@itemcode,@Quantity while @@fetch_status<>-1 begin SET @recnum = (SELECT (T1.CmpltQty-T1.PlannedQty) as recnum from OWOR T1 WHERE T1.ItemCode= @itemcode AND T1.DocNum=@BaseRef) if(@recnum > 0) BEGIN set @error=1 set @error_message=N'收货数量不能大于计划数量' END -----您要执行的操作写在这里 fetch next from YOUCURNAME into @BaseRef,@itemcode,@Quantity END close YOUCURNAME deallocate YOUCURNAME end end