参考K/3 WISE 中MRP计算投放过程中 销售订单自定义字段怎么携带到任务单这篇文章,进行优化。
在表ICMrpDestBills下增加触发器,代码如下
CREATE TRIGGER [dbo].[ICMrpDestBills_update]ON [dbo].[ICMrpDestBills]AFTER INSERT,UPDATE
AS
BEGINSET NOCOUNT ON;----当计划单中投放时,将“关联物料”传递到“组部件”---获取标识,70采购,85生产DECLARE @Status int;select @Status=ftrantype from inserted--处理投放生产任务单
if @Status=85
begin
update t1 set t1.FHeadSelfJ01105=T1.FItemID,t1.FHeadSelfJ01107=t4.FNumber,FHeadSelfJ01104=t4.FName
from
icmo t1
inner join inserted t2 on T1.FInterID=T2.FDestBillInterID
inner join ICMrpResult t3 on t2.FInterID=t3.FRunID AND T1.FPlanOrderInterID=T3.FInterID
inner join t_item t4 on t4.FItemClassID=4 and t3.FHeadSelfJ0554=t4.FItemID
end--处理投放采购申请单
if @Status=70
begin
update t1 set t1.FEntrySelfP0140=T1.FItemID,t1.FEntrySelfP0141=t4.FNumber,T1.FEntrySelfP0137=t4.FName
from
PORequestEntry t1
inner join inserted t2 on T1.FInterID=T2.FDestBillInterID
inner join ICMrpResult t3 on t2.FInterID=t3.FRunID AND T1.FPlanOrderInterID=T3.FInterID
inner join t_item t4 on t4.FItemClassID=4 and t3.FHeadSelfJ0554=t4.FItemID
endEND
生产任务的计划订单
生产任务单
采购任务的计划订单
采购申请单