生产订单:非创建用户无法修改计划数量
小于 1 分钟
控制逻辑
- 获取当前登录用户ID
- 判断当前登录用户是否等于创建用户
- 判断更新的计划数量是否与上一次计划数量相符
图例
代码示例
-生产订单:非创建用户无法修改计划数量
IF @object_type = '202'
BEGIN
IF @transaction_type = 'U'
BEGIN
DECLARE @USERID varchar(20);
SELECT @USERID = c.[USERID]
FROM [master].[dbo].[sysprocesses] a
INNER JOIN [dbo].[USR5] b
ON a.[spid] = b.[SessionID]
AND a.[hostprocess] = b.[ProcessID]
INNER JOIN [dbo].[OUSR] c ON b.[UserCode] = c.[USER_CODE]
WHERE a.[spid] = @@spid
AND b.[Action] = 'I'
ORDER BY b.[Date] DESC;
IF EXISTS (
SELECT T0.[PlannedQty], T0.[UserSign]
FROM OWOR T0
INNER JOIN (
SELECT TOP 1 T0.[PlannedQty], T0.[UserSign2], T0.DocNum
FROM AWOR T0
ORDER BY T0.[UpdateDate] DESC, T0.[UpdateTS] DESC
) TA
ON TA.DocNum = t0.DocNum
WHERE T0.[PlannedQty] <> TA.[PlannedQty]
AND T0.[UserSign] <> @USERID
AND t0.docentry = @list_of_cols_val_tab_del
)
BEGIN
SET @error = 1;;
SET @error_message = '生产订单控制:非创建用户无法修改计划数量!!';;
END;
END;
END