on 10-03-2012 3:35 PM
Dear All,
I am using SAP 8.8.2 PL04 and i have the SP Transaction Notification which is working.
I need assistance in below SP Transaction Notification where i want to Block a user from copying a Sales Order directly to Sales Invoice.
-- ADD YOUR CODE HERE
-- CASH SALS NOT BLOCKING
IF @transaction_type = 'A' AND @object_type = '13'
BEGIN
IF EXISTS (SELECT T0.ItemCode FROM [dbo].[INV1] T0
inner join OINV t1 on t1.DocEntry=t0.docentry
WHERE T0.BaseType <> -1 and t1.CardCode<>'C9999' AND T0.DocEntry = @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 1, @error_message = 'Sales Invoice Not Based on Sales Delivery'
END
END
-- BLOCK SALES DELIVERY QUANTITY GREATER THE SALES ORDER QUANTITY
IF @transaction_type IN (N'A', N'U') AND (@Object_type = N'15')
BEGIN
declare @numlinii int
SELECT @numlinii = (LineNum + 1) FROM DLN1
WHERE DLN1.DocEntry = @list_of_cols_val_tab_del AND
((Quantity > BaseOpnQty))
ORDER BY LineNum ASC
IF (not ISNULL(@numlinii, 0) = 0)
BEGIN
SET @error = 10
SET @error_message = N'Quantity is invalid in Line ' + CONVERT(nvarchar(4), @numlinii) + N' !'
end
END
-- BLOCK GRPO WITHOUT PURCHASE ORDER
IF @transaction_type = 'A' AND @object_type = '20'
BEGIN
IF EXISTS (SELECT T0.ItemCode FROM [dbo].[PDN1] T0
WHERE T0.BaseType = -1 AND T0.DocEntry = @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 1, @error_message = 'Goods Receipt Purchase Order Not Based On Purchase Order'
END
END
-- BLOCK PURCHASE INVOICE WITHOUT GOOD RECEIPT PURCHASE ORDER
IF @transaction_type = 'A' AND @object_type = '18'
BEGIN
IF EXISTS (SELECT T0.ItemCode FROM [dbo].[PCH1] T0
WHERE T0.BaseType <> -1 AND T0.DocEntry = @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 1, @error_message = 'Purchase Invoice Not Based on Goods Receipt Purchase Order'
END
END
-- BLOCK PURCHASE GOODS RETURN WITHOUT GOOD RECEIPT PURCHASE ORDER
IF @transaction_type = 'A' AND @object_type = '21'
BEGIN
IF EXISTS (SELECT T0.ItemCode FROM [dbo].[RPD1] T0
WHERE T0.BaseType = -1 AND T0.DocEntry = @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 1, @error_message = 'Purchase Goods Return Not Based on Goods Receipt Purchase Order'
END
END
-- BLOCK SALES RETURN WITHOUT SALES DELIVERY
IF @transaction_type = 'A' AND @object_type = '16'
BEGIN
IF EXISTS (SELECT T0.ItemCode FROM [dbo].[RDN1] T0
WHERE T0.BaseType = -1 AND T0.DocEntry = @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 1, @error_message = 'Sales Return Not Based on Sales Delivery'
END
END
-- BLOCK SALES DELIVERY WITHOUT SALES ORDER
IF @transaction_type = 'A' AND @object_type = '15'
BEGIN
IF EXISTS (SELECT T0.ItemCode FROM [dbo].[DLN1] T0
WHERE T0.BaseType = -1 AND T0.DocEntry = @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 1, @error_message = 'Sales Delivery Not Based on Sales Order'
END
END
-- Select the return values
select @error, @error_message
end
Hi Rajindra,
Please try this, it will Block specific user for creating Sales Invoice without Delivery.
IF @transaction_type = 'A' and @object_type = '13'
BEGIN
IF EXISTS (SELECT T0.ItemCode FROM [dbo].[INV1] T0
inner join OINV T1 on T1.DocEntry=T0.docentry
Inner Join OUSR T2 ON T2.UserID = T1.UserSign
WHERE T0.BaseType <> -1 and t1.CardCode<>'C9999' AND T0.DocEntry = @list_of_cols_val_tab_del and T1.UserSign IN ('1','2'))
BEGIN
SELECT @Error = -10000, @error_message = 'Sales Invoice Not Based on Sales Delivery'
END
END
Hope this help.
Replace T1.UserSign with your user UserId, whom you want to Block creating Sales Invoice without Delivery.
Thanks'
--
--
Regards::::
Atul Chakraborty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try:
IF @transaction_type = 'A' AND @object_type = '13'
BEGIN
IF EXISTS (SELECT T0.DocEntry FROM [dbo].[INV1] T0
INNER join OINV t1 on t1.DocEntry=t0.docentry
WHERE T0.BaseType = 17 and t1.CardCode<>'C9999' AND T0.DocEntry = @list_of_cols_val_tab_del)
Begin
SELECT @Error = 13, @error_message = 'Sales Invoice is Not Based on Sales Delivery'
End
END
Thanks,
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Rajindra Parmar
IF @transaction_type = 'A' AND @object_type = '13'
BEGIN
IF EXISTS (SELECT T0.ItemCode FROM [dbo].[INV1] T0
inner join OINV t1 on t1.DocEntry=t0.docentry
WHERE (T0.BaseType <> -1 or T0.BaseType ='17' ) and t1.CardCode<>'C9999' AND T0.DocEntry = @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 1, @error_message = 'Sales Invoice Not Based on Sales Delivery'
END
END
Hope Helpful
Regards
Kennedy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
7 | |
6 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.