Validate BOM Item Code,Project and Allow Procurement for Sales Order
IF @transaction_type IN (N'A', N'U') AND (@Object_type = N'17')
BEGIN
set @entry= (select distinct DOCENTRY from RDR1 where DocEntry=@list_of_cols_val_tab_del )
IF EXISTS (SELECT DISTINCT T1.ITEMCODE FROM [DBO].RDR1 T1 WHERE T1.LinePoPrss='Y' )
BEGIN
IF NOT Exists (SELECT DISTINCT T1.ItemCode FROm [DBO].OITT T0 INNER JOIN [DBO].RDR1 T1 ON T1.itemcode=T0.CODE where T1.DocEntry = @entry)
BEGIN
SELECT @Error = 5, @error_message = 'Item Code BOM is missing !'
END
ELSE IF NOT EXISTS( SELECT DISTINCT T1.Project FROm [DBO].OITT T0 INNER JOIN [DBO].RDR1 T1 ON T1.itemcode=T0.CODE AND T1.PROJECT IS not NULL WHERE T1.DocEntry = @entry)
BEGIN
SELECT @Error = 5, @error_message = 'Project Code is missing !'
END
ELSE IF NOT EXISTS( SELECT DISTINCT T1.LinePoPrss FROm [DBO].OITT T0 INNER JOIN [DBO].RDR1 T1 ON T1.itemcode=T0.CODE AND T1.LinePoPrss='Y' WHERE T1.DocEntry = @entry)
BEGIN
SELECT @Error = 5, @error_message = 'Allow Procurement is not checked !'
END
END
END