on 03-11-2013 11:05 PM
Hola buen día a todos,
Tengo el siguiente transacion que me valida el Stock actual al crear mi factura de reserva, pero pasa que si hay varias lineas no esta funcionando correctamente, si la factura solamente tiene un articulo funciona bien ... a ver si me pueden ayudar, gracias de antemano!
if @object_type = '13' and @transaction_type in ('A')
begin
Declare @Articulofact int
Declare @Stock int
Set @Articulofact = (Select t0.quantity from inv1 t0 where T0.DocEntry = @list_of_cols_val_tab_del)
Set @Stock = (Select T2.[OnHand] from INV1 T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN OITW T2 ON T1.ItemCode = T2.ItemCode where t0.Docentry = @list_of_cols_val_tab_del and T2.[WhsCode] = T0.[WhsCode])
if @Articulofact > @Stock
begin
set @error = 451587
set @error_message = 'Articulo Sin Stock'
end
end
Hola Victor, Intenta así:
If @object_type = '13' AND @transaction_type in ('A')
BEGIN
If exists
(Select b.ItemCode
From OINV a
inner join INV1 b on a.DocEntry=b.DocEntry
inner join OITM c On b.ItemCode=c.ItemCode
INNER JOIN OITW d ON c.ItemCode = d.ItemCode
Where a.DocEntry = @list_of_cols_val_tab_del
and b.quantity > d.onhand)
Begin
set @error =1
set @error_message = 'Articulo sin Stock '
End
END
Saludos.
Alessandro.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Agregue solamente la validación de mismo almacén para ItemCode en INV1 y OITW y parece que funciona correctamente.
Muchísimas gracias Alessandro !!!!
Así quedo:
If @object_type = '13' AND @transaction_type in ('A')
BEGIN
If exists
(Select b.ItemCode
From OINV a
inner join INV1 b on a.DocEntry=b.DocEntry
inner join OITM c On b.ItemCode=c.ItemCode
INNER JOIN OITW d ON c.ItemCode = d.ItemCode
Where a.DocEntry = @list_of_cols_val_tab_del
and b.WhsCode = d.WhsCode
and b.quantity > d.onhand)
Begin
set @error =1
set @error_message = 'Articulo sin Stock '
End
END
User | Count |
---|---|
94 | |
11 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.