Esto habia avanzado pero hay error cuando son varios items dentro de la orden
If (:object_type='17' and (:transaction_type = 'U')) THEN
SELECT T0."Quantity" into cantOV1 FROM RDR1 T0 WHERE (T0."DocEntry"=:list_of_cols_val_tab_del );
(SELECT T0."Quantity" into cantOV2 FROM ADO1 T0 WHERE T0."ObjType" = :object_type AND (T0."DocEntry" = :list_of_cols_val_tab_del) AND
T0."LogInstanc"= (SELECT TOP 1 Y."LogInstanc" FROM ADOC Y WHERE (Y."DocEntry" = :list_of_cols_val_tab_del) AND Y."ObjType" = :object_type
ORDER BY Y."LogInstanc" DESC));
if ( cantOV1<>cantOV2)
THEN
error:=1904;
error_message:=' No esta autorizado para modificar estos campos';
End IF;
End IF;
Esta seria la forma con un solo campo, como el de cantidad:
If (:object_type='17' and (:transaction_type = 'U')) THEN
If (select count(*) from ORDR T0
inner join RDR1 T1 on T1."DocEntry" = T0."DocEntry"
where T0."DocEntry" =:list_of_cols_val_tab_del
and T1."LineTotal" <>
(select top 1 A."LineTotal" from ADO1 A where A."DocEntry" = T1."DocEntry"
and A."LineNum" = T1."LineNum" and A."ObjType" = T1."ObjType"
order by A."DocDate" DESC)
) > 0
THEN
error := 22;
error_message := ' No esta autorizado para modificar estos campos';
End IF;
End IF;
End IF;
A todos muchas gracias ya logre que funcionara , al final asi me quedo .
If (:object_type='17' and (:transaction_type = 'U'))
THEN
select count(*) into cantidad from ORDR T0
inner join RDR1 T1 on T1."DocEntry" = T0."DocEntry"
where T0."DocEntry" =:list_of_cols_val_tab_del
and T1."Quantity" <>
(SELECT T0."Quantity" FROM ADO1 T0
WHERE T0."ObjType" = :object_type AND (T0."DocEntry" = :list_of_cols_val_tab_del) AND
T0."LineNum" = T1."LineNum" AND T0."LogInstanc"=
(SELECT TOP 1 Y."LogInstanc" FROM ADOC Y WHERE (Y."DocEntry" = :list_of_cols_val_tab_del)
ORDER BY Y."LogInstanc" DESC) ) ;
If(cantidad>0)
THEN
error := 22;
error_message := ' No esta autorizado para modificar estos campos';
End IF;
End IF;