Dear All,
I have learnt so many things from this SAP SCN blogs, documents and also from the experts who are supporting SAP Business one Consultants,
Thanks for
Mr.Nagarajan
Mr. Kennedy T
Mr. Andakonda Ramudu
-----******-------
I have written some transaction notifications, hope this will help you .
------Cannot Add Good Receipt PO without Purchase Order (FOR only item type)-----------
IF @object_type = '20'
AND @transaction_type IN ('A', 'U')
BEGIN
IF EXISTS(
SELECT t1.docentry
FROM opdn t1
INNER JOIN pdn1 t2
ON t1.docentry = t2.docentry
WHERE @list_of_cols_val_tab_del = t1.docentry
AND t2.BaseType<>'22' AND t1.DocType='I'
)
BEGIN
SET @error = -1
SET @error_message = 'You Cannot Add Good Receipt PO without Purchase Order'
END
END
------Cannot Add Good Return without Goods Receipt PO (FOR only item type)-----------
IF @object_type = '21'
AND @transaction_type IN ('A', 'U')
BEGIN
IF EXISTS(
SELECT t1.docentry
FROM orpd t1
INNER JOIN rpd1 t2
ON t1.docentry = t2.docentry
WHERE @list_of_cols_val_tab_del = t1.docentry
AND t2.BaseType<>'20' AND t1.DocType='I'
)
BEGIN
SET @error = -1
SET @error_message = 'You Cannot Add Good Return without Goods Receipt PO'
END
END
-- BLOCK PURCHASE INVOICE WITHOUT GOOD RECEIPT PURCHASE ORDER(FOR only item type)----
IF @object_type = '18'
AND @transaction_type IN ('A', 'U')
BEGIN
IF EXISTS(
SELECT t1.docentry
FROM opch t1
INNER JOIN pch1 t2
ON t1.docentry = t2.docentry
WHERE @list_of_cols_val_tab_del = t1.docentry
AND t2.BaseType<>'20' AND t1.DocType='I'
)
BEGIN
SET @error = -1
SET @error_message = 'You Cannot Add GPURCHASE INVOICE WITHOUT GOODS RECEIPT PURCHASE ORDER'
END
END
------Cannot Add Delivery Note without Sales Order (FOR only item type)-----------
IF @object_type = '15'
AND @transaction_type IN ('A', 'U')
BEGIN
IF EXISTS(
SELECT t1.docentry
FROM odln t1
INNER JOIN dln1 t2
ON t1.docentry = t2.docentry
WHERE @list_of_cols_val_tab_del = t1.docentry
AND t2.BaseType<>'17' AND t1.DocType='I'
)
BEGIN
SET @error = -1
SET @error_message = 'You Cannot Add Delivery Note without Sales Order'
END
END
------Cannot Add Return without Delivery Note (FOR only item type)-----------
IF @object_type = '16'
AND @transaction_type IN ('A', 'U')
BEGIN
IF EXISTS(
SELECT t1.docentry
FROM ordn t1
INNER JOIN rdn1 t2
ON t1.docentry = t2.docentry
WHERE @list_of_cols_val_tab_del = t1.docentry
AND t2.BaseType<>'15' AND t1.DocType='I'
)
BEGIN
SET @error = -1
SET @error_message = 'You Cannot Add Return without Delivery Note'
END
END
-- BLOCK SALES INVOICE WITHOUT Delivery Note (FOR only item type)----
IF @object_type = '13'
AND @transaction_type IN ('A', 'U')
BEGIN
IF EXISTS(
SELECT t1.docentry
FROM oinv t1
INNER JOIN inv1 t2
ON t1.docentry = t2.docentry
WHERE @list_of_cols_val_tab_del = t1.docentry
AND t2.BaseType<>'15' AND t1.DocType='I'
)
BEGIN
SET @error = -1
SET @error_message = 'You Cannot Add SALES INVOICE WITHOUT DELIVERY NOTE'
END
END
--------------------------------------------
Thank you