Production Order Stored Procedure Blocking Issue for Production

Hi Experts,
I’m using following Stored procedure to block updating Planned qty in production order 
but this stored procedure is blocking users from entering Issue for Production that includes machine or labour

 
IF @object_type=’202′ AND @transaction_type = ‘U’
 
Begin
 
IF EXISTS (SELECT T0.DocEntry
FROM OWOR T0 
inner join WOR1 T1 on t0.docentry = t1.docentry
inner join AWOR T2 on t2.DocEntry =t0.DocEntry 
inner join AWO1 T3 on t3.LogInstanc = T2.LogInstanc and t3.DocEntry=t2.DocEntry and t1.LineNum =t3.LineNum and t1.ItemCode = t3.ItemCode
WHERE T0.DocEntry = @List_of_cols_val_tab_del 
and T2.status =’R’
and T0.Status = ‘R’
and T0.ItemCode like ‘F%’
and t0.UserSign2 != ‘1’
and t3.LogInstanc = (Select MAX(AWO1.loginstanc) from AWO1 where AWO1.docentry =@list_of_cols_val_tab_del )
AND T0.CreateDate > ‘20241111’
GROUP BY T0.DocEntry
   HAVING SUM(T1.PlannedQty) <> SUM(T3.PlannedQty)
)
 
BEGIN
 
SET @error = 2023021501
SET @error_message = ‘Not authorized to Update Planned Qty in  Released Production Order’
 
END
 
END
Scroll to Top