on 09-22-2010 1:32 AM
tengo el siguiente codigo para utilizar en bloqueos de ordenes y ofertas de ventas con un campo usuario.
pero no me valida cuando hace un update y tengo duda si es por que tengo varios if...
IF @object_type = '17' and @transaction_type IN ('A','U')
BEGIN
if exists (SELECT T1.[ItemCode]
FROM ORDR T0
INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OITM T2 ON T1.ITEMCODE=T2.ITEMCODE
WHERE (T1.[price] <= T2.[avgprice])and (T0.docentry = @list_of_cols_val_tab_del)
and (t1.itemcode<>'PREF-15')and(t1.itemcode<>'POLV-17'))
begin
SELECT @error = 1, @error_message = 'orden de venta con precio bajo de costo !'
end
END
IF (@object_type = '17') and (@transaction_type='A')
BEGIN
if exists (SELECT T0.[docnum]
FROM ORDR T0
WHERE (t0.u_codigo='')and (T0.docentry = @list_of_cols_val_tab_del))
begin
SELECT @error = 1, @error_message = 'orden de venta sin código de vendedor!'
end
END
IF (@object_type = '17') and (@transaction_type='U')
BEGIN
if exists (SELECT T0.[docnum]
FROM ORDR T0
WHERE (t0.u_codigo='')and (T0.docentry = @list_of_cols_val_tab_del))
begin
SELECT @error = 1, @error_message = 'Oferta de Venta sin código de vendedor!'
end
END
IF @object_type = '23' and @transaction_type='A'
BEGIN
if exists (
SELECT T0.[docnum]
FROM OQUT T0
WHERE (t0.u_codigo='')and (T0.docentry = @list_of_cols_val_tab_del)
)
begin
SELECT @error = 1, @error_message = 'Oferta de Venta sin código de vendedor!'
end
END
IF (@object_type = '23') and (@transaction_type='U')
BEGIN
if exists (
SELECT T0.[docnum]
FROM OQUT T0
WHERE (t0.u_codigo='')and (T0.docentry = @list_of_cols_val_tab_del))
begin
SELECT @error = 1, @error_message = 'Oferta de Venta sin código de vendedor!'
end
END
y no me funciona bien, al actualizar una oferta de venta me deja que vaya sin codigo, alguien
puede ayudarme?.
Hola...
Viendo el código estás repitiendo para la rutina de validación de una oferta, el objeto de Orden de Venta 17 y la tabla ORDR. El mensaje dice Oferta pero no apunta a los datos correctos.
Borra el código
IF (@object_type = '17') and (@transaction_type='U')
BEGIN
if exists (SELECT T0.[docnum]
FROM ORDR T0
WHERE (t0.u_codigo='')and (T0.docentry = @list_of_cols_val_tab_del))
begin
SELECT @error = 1, @error_message = 'Oferta de Venta sin código de vendedor!'
end
END
Con eso no deberías ya tener problemas
Puedes intentarlo así....
IF (@object_type = '17') and (@transaction_type='A' or @transaction_type = 'U')
BEGIN
if exists (SELECT T0.[docnum]
FROM ORDR T0
WHERE (t0.u_codigo='')and (T0.docentry = @list_of_cols_val_tab_del))
begin
SELECT @error = 1, @error_message = 'orden de venta sin código de vendedor!'
end
END
IF (@object_type = '23') and (@transaction_type='A' or @transaction_type = 'U')
BEGIN
if exists (SELECT T0.[docnum]
FROM OQUT T0
WHERE (t0.u_codigo='')and (T0.docentry = @list_of_cols_val_tab_del))
begin
SELECT @error = 1, @error_message = 'Oferta de Venta sin código de vendedor!'
end
END
Saludos Cordiales,
Edited by: Paul Ponce on Sep 22, 2010 3:11 AM
Edited by: Paul Ponce on Sep 22, 2010 3:29 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola..
2 cosas, la primera es que viendo el tema me pregunto el porqué no te serviría las autorizaciones de actualizar empleado de ventas, que aparece en el modulo de Autorizaciones.
La segunda, es que viendo tu código entiendo que trabajas con un campo de usuario, el cual asumo puede o no tener valores. Resulta que probé el transaction y no me funcionó, pero lo cambié solo en la parte del '' por NULL y si me funcionó perfectamente.
Intenta probando el siguiente código...
IF (@object_type = '23') and (@transaction_type='A' or @transaction_type = 'U')
BEGIN
DECLARE @COD NVARCHAR(10)
SET @COD = (SELECT T0.U_codigo FROM OQUT T0 WHERE T0.DocEntry = @list_of_cols_val_tab_del)
IF @COD is null
BEGIN
SELECT @error = 1
SELECT @error_message = 'Oferta de Venta sin código de vendedor!'
END
END
Espero te sea de ayuda
Saludos Cordiales,
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
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.