on 06-25-2014 4:03 PM
Buen dia compañeros, estoy realizando un bloqueo de orden de fabricacion, la cual no se debe crear si existieran ordenes con fecha de finalizacion superior a 3 dias de vencimiento. Hice un TSQL pero no me esta bloqueando y tengo 4 ordenes que cumplen con la restriccion, si alguien me pudiera ayudar a optimizar el transaction, de antemano muchas gracias.
saludos cordiales
IF @object_type in ('202') and @transaction_type in ('A', 'U')
begin
if exists(select 1
from OWOR T0
inner join WOR1 T1 on T0.DocEntry = T1.DocEntry
where T0.DocEntry = @list_of_cols_val_tab_del
and datediff(dd,GETDATE(),T0.DueDate)> 3)
begin
SELECT @error = 1, @error_message = 'Imposible crear Orden de Fabricacion , Existen ordenes con mas de 3 dias de vencimiento!!'
end
end
Hola amando,
Prueba invirtiendo duedate primero y luego getdate()
datediff(dd,T0.DueDate,GETDATE())>3)
Saludos,
Wuilmer Venegas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gracias, por tomarte tu tiempo, si ya me habia percatado que era porque la fecha me salia negativa y no me daba el dato que requeria. saludos cordiales
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola Armando,
Parece que estás pasando como filtro el propio docentry de la orden a crear (T0.DocEntry = @list_of_cols_val_tab_del), por lo que la consulta no te devuelve ningún valor (en el caso de que la orden que estás creando no supere el límite de los 3 días).
Quizás podrías probar con:
select 1 from OWOR T0
inner join WOR1 T1 on T0.DocEntry = T1.DocEntry
where datediff(dd,GETDATE(),T0.DueDate)> 3
(para verificar sobre todas las órdenes ya existentes, no sólo la que estás creando en ese momento).
Un saludo, Borja.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
8 | |
7 | |
4 | |
4 | |
3 | |
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.