Goodafternoonexpertscommunity'm doing a lockwhichIdoubtasraise it, the case is as follows:
The purchase ordershould notbe created if theunit price of theitem ishigher than the priceofthe price listofsap, the problem is that nowthey will start touse the extracoinprice list, that is why it isrequiresblockingthecreation ofthe purchase orderif theorder priceis higherornotapplicabletothe two alternativeswe have inour price list.
In advanceI will begratefulif anyonereadsthispostand I canreach outto fillthis requirementandalsobring somethingmoreto myknowledge.
best regards!
example
if @transaction_type = 'A' and @object_type='22'
begin
set @itemcode =(select top(1) o1.itemcode
from opor o inner join por1 o1 on o1.docEntry = o.docEntry
inner join ocrd c on c.cardcode = o.cardcode
where u_facnum is not null
and not exists(
select *
from itm1
where itemcode = o1.itemcode
and pricelist = c.listnum
and (price > o1.Price and AddPrice1 > o1.Price or itemcode in ('FLETE','SEGURO'))
)
and o.docEntry = @DocEntry)
if (
select count(*)
from opor o inner join por1 o1 on o1.docEntry = o.docEntry
inner join ocrd c on c.cardcode = o.cardcode
where u_facnum is not null
and not exists(
select *
from itm1
where itemcode = o1.itemcode
and pricelist = c.listnum
and (price > o1.Price and AddPrice1 > o1.Price or itemcode in ('FLETE','SEGURO'))
)
and o.docEntry = @DocEntry
)>0
begin
set @error = 1
set @error_message = 'Error el articulo '+@itemcode+' no concuerda a lista de precios del cliente.!'
end
end