SAP B1 用存储过程控制生产收货(收货数量+已完成数量不能大于计划数量)

软件环境:SAP business One 9.2 (PL10)

解决方案:修改后台数据库的存储过程(SBO_SP_TransactionNotification),添加控制单据操作的业务逻辑代码,代码如下:

--生产收货,收货数量加已完成数量不能大于计划数量。注: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

最后,感谢“博客园”的博主“mingxiu”的思路和源码,原文出处:https://www.cnblogs.com/sapb1/p/5435367.html

展开阅读全文

没有更多推荐了,返回首页