on 01-23-2012 9:55 PM
Estimado Amigos:
Estoy ya varias horas dando vueltas con este tema, y quiero validar dos campos para que no permita la actulizacion en la factura
Hice esta validacion pero no se que estara mal porque solo quiero que no se actualize cuando estos campos no coincidan despues si quisiera que deje actualizar el documento para cualquier comentario
lo que hace esta validacion o mejor dicho lo que quiero es comparar los campos:
numero de referencia de la factura
y el campo Ref2 del asiento que se genera al crear la factura.
-- NO PERTMITE ACTUALIZAR EL CAMPO DE CORRELATIVO EN LA FACTURA DE VENTAS
IF @TRANSACTION_TYPE IN ('U') AND @OBJECT_TYPE IN ('13')
BEGIN
DECLARE @CORREFC as NVarchar(15)
DECLARE @REF2FC as NVarchar(15)
SELECT @REF2FC = COUNT(T0.REF2) FROM OJDT T0 WHERE T0.Number = @list_of_cols_val_tab_del
SELECT @CORREFC = COUNT(T0.NUMATCARD) FROM OINV T0 WHERE T0.DOCENTRY = @list_of_cols_val_tab_del
IF (@REF2FC != @CORREFC)
BEGIN
SET @error = 102
SET @error_message = 'NO SE PUEDE ACTUALIZAR EL CAMPO DE CORRELATIVO. YA SE ASIGNO UN CORRELATIVO AL DOCUMENTO'
END
END
Por favor si me pueden ayudar ya que como comento no me deja actualizar nada y solo quisiera que no me dejara actualizar si estos campos no coinciden
Otra consulta hay manera de poner inactivo un campo de usuario una vez creado el documento??
Intenta asi, pues no puedes comparar la informacion del asiento si lo que estas actualizando es el objeto 13 (tabla facturas)
-- NO PERTMITE ACTUALIZAR EL CAMPO DE CORRELATIVO EN LA FACTURA DE VENTAS
IF @TRANSACTION_TYPE IN ('U') AND @OBJECT_TYPE IN ('13')
BEGIN
DECLARE @CORREFC as NVarchar(15)
DECLARE @REF2FC as NVarchar(15)
SELECT @REF2FC = COUNT(T0.REF2) FROM OJDT T0 WHERE T0.Baseref = @list_of_cols_val_tab_del
SELECT @CORREFC = COUNT(T0.NUMATCARD) FROM OINV T0 WHERE T0.DOCENTRY = @list_of_cols_val_tab_del
IF (@REF2FC != @CORREFC)
BEGIN
SET @error = 102
SET @error_message = 'NO SE PUEDE ACTUALIZAR EL CAMPO DE CORRELATIVO. YA SE ASIGNO UN CORRELATIVO AL DOCUMENTO'
END
END
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gracias pero no funciono
no se si me exprese bien pero lo que quiero es comparar estos dos campos
Numero de referencia del deudor de la Factura
Ref2 del Asiento
Ambos campos contienen el correlativo de la factura los cuales se graban por defecto al crear la factura
Esos valores en esos campos quisiera comparar y si no son iguales no permita actualizar y si son iguales si permita.
Usalo asi
-- NO PERTMITE ACTUALIZAR EL CAMPO DE CORRELATIVO EN LA FACTURA DE VENTAS
IF @TRANSACTION_TYPE IN ('U') AND @OBJECT_TYPE IN ('13')
BEGIN
DECLARE @CORREFC as NVarchar(15)
DECLARE @REF2FC as NVarchar(15)
SELECT @REF2FC = T0.REF2 FROM OJDT T0 WHERE T0.Baseref = @list_of_cols_val_tab_del
SELECT @CORREFC = T0.NUMATCARD FROM OINV T0 WHERE T0.DOCENTRY = @list_of_cols_val_tab_del
IF (@REF2FC != @CORREFC)
BEGIN
SET @error = 102
SET @error_message = 'NO SE PUEDE ACTUALIZAR EL CAMPO DE CORRELATIVO. YA SE ASIGNO UN CORRELATIVO AL DOCUMENTO'
END
END
Porque habias puesto un count a un campo nvarchar??
BUENO LO PUSE PARA QUE CUENTEN CUANTOS VALORES COINCIDEN SOLO DEBE SER UNO SI ES MAS SALTA EL ERROR
PERO BUENO PROBE Y PASA LO MISMO QUE CON EL PRIMER QUERY QUE PUSE. NO PERMITE ACTUALIZAR NADA.
SOLO QUISIERA QUE SE NO ACTUALIZA SI:
EL CAMPO DE REFERENCIA DE LA FACTURA
VS.
EL CAMPO REF2 DEL ASIENTO (GENERADO POR ESA FACTURA AL CREARSE)
NO SEAN IGUALES
OSEA TENGO EL CASO DE QUE POR ERROR MODIFICAN EL CAMPO DE REFERENCIA Y ACTUALIZAN PERO NO QUISIERA QUE LO ACTUALIZEN YA QUE AL NO COINCIDIR CON EL REF2 DEL ASIENTO SALTE EL ERROR
PERO SI QUISIERA QUE ACTUALIZEN POR DECIR QUE PONGAN UN COMENTARIO O CAMBIEN EL ESTADO DEL DOCUMENTO POR ANULADO, SI ESTOS CAMPOS SON IGUALES
Esta fue la solucion a mi problema espero que les sea de utilidad
if (@object_type ='15' and @transaction_type='U') -- Guia de Remision
begin
DECLARE @CORRDOCG AS NVARCHAR(13)
DECLARE @CORRLOCG AS NVARCHAR(13)
set @CORRDOCG=(select top 1 U_BPP_MDCD from ODLN where docentry=@list_of_cols_val_tab_del)
set @CORRLOCG=(
SELECT TOP 1 X.U_BPP_MDCD
FROM
(select U_BPP_MDCD,loginstanc
from adoc
where objtype='15' and docentry=@list_of_cols_val_tab_del
AND Loginstanc=(SELECT MAX(LOGINSTANC) FROM ADOC WHERE objtype='15' and docentry=@list_of_cols_val_tab_del)) X
)
--set @usuario_aux=(select top 1 usersign2 from orpc where docentry=@list_of_cols_val_tab_del)
--set @areaUSER =(select top 1 department from ousr where userid=@usuario_aux)
if @CORRDOCG<>@CORRLOCG
begin
set @error=1
set @aux=' AE :No puede cambiar el correlativo de este documento '+@CORRDOCG+' '+@CORRLOCG
set @error_message=@list_of_key_cols_tab_del+' '+@list_of_cols_val_tab_del+' '+@aux
end
end
User | Count |
---|---|
103 | |
14 | |
10 | |
5 | |
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.