跳至主要內容

生产订单:自动更新库存转储数量(10.0专用)

五六零网校小于 1 分钟

自定义字段

  • 生产订单行字段:已库存转储数 代码:U_YZCS\

代码示例

--生产订单:自动更新库存转储数量
IF @object_type = '67'
BEGIN
IF @transaction_type = 'A'
OR @transaction_type = 'U'
BEGIN
	UPDATE T0
SET T0.U_YZCS = T1.ZC
FROM
	WOR1 T0
LEFT JOIN (
SELECT
		T0.[RefDocNum] AS 'SC',
		T1.[ItemCode],
		SUM(TS.[Quantity])  AS 'ZC'
	FROM
		WTQ21 T0
	INNER JOIN WTQ1 T1 ON T1.[DocEntry] = T0.[DocEntry]
	INNER JOIN (
		SELECT
			T0.[BaseEntry],
			T0.[ItemCode],
			T0.[Quantity] 
		FROM
			WTR1 T0
	) TS ON TS.[BaseEntry] = T1.docentry
	AND TS.[ItemCode] = T1.itemcode
	WHERE
		T0.[RefObjType] = '202'
GROUP BY
	T0.[RefDocNum],
	T1.[ItemCode]
) T1 ON T1.sc = t0.docentry
AND T1.[ItemCode] = t0.itemcode
END
END