Skip to Content
0
Oct 03, 2012 at 02:35 PM

How to Block Sales Order Being Copied Directly to Sales Invoice

11 Views

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