如何阻止在 SAP B1 中添加文档 - 如果未选择特定项目 - TN 阻止

How to block adding of document in SAP B1 - If not certain item selected - TN Blocking

我的问题是:

如何不允许在 SAP b1 中使用 TN 阻塞添加文档。如果不是某个项目没有被选中?

我试过这个:

If @object_type='202' and @transaction_type in('A','U')
BEGIN
declare @SlitCount Integer
declare @CountSlit integer

select @SlitCount = (SELECT T1.DocEntry FROM OWOR T0  INNER JOIN WOR1 T1 ON T0.[DocEntry] = T1.[DocEntry] 
                            WHERE T0.DocEntry = @list_of_cols_val_tab_del AND T1.ItemCode = 'Item One'
                            GROUP BY T1.DocEntry
                            Having Count(T0.ItemCode) <= 1)

If exists (SELECT T0.DocEntry,@CountSlit FROM OWOR T0 INNER JOIN WOR1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.DocEntry= @list_of_cols_val_tab_del AND @CountSlit = 0
) 
Begin
    Select @error = 101,
    @error_message = 'Item One is not selected'
  End
END

谢谢!

如果您不需要检查来自 headers 的数据,这应该可以正常工作

If @object_type='202' and @transaction_type in('A','U')
BEGIN
declare @SlitCount Integer

@SlitCount = (SELECT COUNT(*) FROM WOR1 WHERE DocEntry = @list_of_cols_val_tab_del AND ItemCode = 'Item One' )

If @SlitCount < 1
Begin
    Select @error = -532783351,
    @error_message = 'Item One is not selected'
  End
END