Try this
-- For AP Invoice Draft Document
IF @transaction_type IN ('U') AND @Object_type = '112'
BEGIN
IF EXISTS (SELECT T0.DocNum
FROM Odrf AS T0
where T0.DocEntry = @list_of_cols_val_tab_del and t0.ObjType = 18)
BEGIN
SELECT @Error = 7, @error_message = 'A\P Draft Update restricted'
END
END
-- For AP Invoice Document
IF @transaction_type IN ('U') AND @Object_type = '18'
BEGIN
IF EXISTS (SELECT T0.DocNum
FROM OPCH AS T0
where T0.DocEntry = @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 7, @error_message = 'A\P Inv. Update restricted'
END
END