跳至主要內容

生产订单:生产订单行物料必须与BOM相符

五六零网校小于 1 分钟

注意

限制生产订单行物料必须与BOM相符

代码示例

--生产订单:生产订单行物料必须与BOM相符
IF @object_type = '202'
	BEGIN
		IF @transaction_type = 'A'
		OR @transaction_type = 'U'
			BEGIN
				IF EXISTS (
					SELECT T1.[ItemCode], T2.[Code]
					FROM OWOR T0
						INNER JOIN WOR1 T1 ON T0.[DocEntry] = T1.[DocEntry]
						FULL JOIN ITT1 T2
						ON T2.father = t0.itemcode
							AND t2.code = t1.itemcode
					WHERE T2.[Code] IS NULL
						AND T0.DocEntry = @list_of_cols_val_tab_del
				)
					BEGIN
						SET @error = 56003;
						SET @error_message = N'生产订单行物料与BOM清单不符!!!';
					END;
				BEGIN
					IF EXISTS (
						SELECT COUNT(t1.ItemCode)
						FROM OWOR T0
							INNER JOIN WOR1 T1 ON T0.[DocEntry] = T1.[DocEntry]
						WHERE T0.DocEntry = @list_of_cols_val_tab_del
						GROUP BY t0.itemcode
						HAVING COUNT(t1.itemcode) <> (
							SELECT COUNT(t2.code)
							FROM ITT1 T2
							WHERE t2.father = t0.itemcode
						)
					)
						BEGIN
							SET @error = 56004;
							SET @error_message = N'生产订单行数与BOM清单不符!!!';
						END;
				END;
			END;
	END