My Question is :
How to not allow adding document using TN Blocking in SAP b1. If not a certain item is not selected?
I Tried this:
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
Thanks!
Advertisement
Answer
If you don’t need to check data from headers, this should work properly
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