跳至主要內容

库存转储单:不能超过转储申请单数量

五六零网校小于 1 分钟

代码示例

--库存转储单:不能超过转储申请单数量
IF @object_type = '67'
	BEGIN
		IF @transaction_type = 'A'
			BEGIN
				IF EXISTS (
					SELECT SUM(t1.quantity), t1.baseentry, t1.baseline, t2.quantity
					FROM wtr1 t1
						INNER JOIN wtq1 t2
						ON t1.baseentry = t2.docentry
							AND t1.baseline = t2.linenum
					WHERE t1.basetype = '1250000001'
						AND t1.docentry NOT IN (
							SELECT baseentry
							FROM wtr1
							WHERE basetype = '67'
						)
						AND CONVERT(VARCHAR(10), T1.BASEENTRY) + '-' + CONVERT(VARCHAR(10), T1.BaseLine) IN (
							SELECT CONVERT(VARCHAR(10), BASEENTRY) + '-' + CONVERT(VARCHAR(10), BaseLine)
							FROM wtr1
							WHERE DocEntry = @list_of_cols_val_tab_del
						)
					GROUP BY t1.baseentry, t1.baseline, t2.quantity
					HAVING SUM(t1.quantity) > t2.quantity
				)
					BEGIN
						SET @error = 67;
						SET @error_message = '已超入库申请数量';
					END;
			END;
	END