on 11-30-2015 9:23 PM
Hola buenas tardes, estoy tratando de hacer una TN en la cual solo me permita digitar dos opciones en el campo Número de Referencia en la factura de venta, el código que tengo es el siguiente:
IF (@object_type = '13')
BEGIN
IF EXISTS
(select NumAtCard from OINV where DocEntry = CAST(@list_of_cols_val_tab_del AS NVARCHAR(15))
and ((NumAtCard in ('Servicios','Eventos','') and DocType= 'S' )))
BEGIN
SET @error_message = 'Número de referencia deber ser Servicios o Eventos'
SET @error = 2122
END
END
Les agradezco su ayuda.
Saludos,
Si quieres que te bloquee el documento cuando la factura sea de tipo Servicio y no tenga el texto Servicios o Eventos, intenta con este código:
IF (@object_type = '13')
BEGIN
IF EXISTS
(select NumAtCard
from OINV
where DocEntry = CAST(@list_of_cols_val_tab_del AS NVARCHAR(15))
and ((NumAtCard not in ('Servicios','Eventos','') and DocType= 'S' )))
BEGIN
SET @error_message = 'Número de referencia deber ser Servicios o Eventos'
SET @error = 2122
END
END
Lo que hice fue agregar un "not" en la línea 7 de tu código.
Saludos,
JC.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
El problema es con el campo vacío. Intenta así:
IF (@object_type = '13')
BEGIN
IF EXISTS
(select NumAtCard from OINV where DocEntry = @list_of_cols_val_tab_del
and (isnull(NumAtCard,'') not in ('Servicios','Eventos','') or len(isnull(NumAtCard,''))=0) and DocType= 'S')
BEGIN
SET @error_message = 'Número de referencia deber ser Servicios o Eventos'
SET @error = 2122
END
END
Saludos,
JC.
te falta indicar que
IF @object_type in ( 13) AND @Transaction_Type in ('A')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Intenta con
IF (@object_type in (13) and @transaction_type in ('A')
BEGIN
declare @opcion as nvarchar(10)
declare @tipodocto as nvarchar (1)
set @opcion= (select NumAtCard from OINV where DocEntry = @list_of_cols_val_tab_del)
set @tipodocto=(select doctype from oinve where docentry=@listo_of_cols_val_tab_del)
if @opcion not in ('Servicios','Eventos') and @tipodocto !='S'
BEGIN
SET @error = 2122
SET @error_message = 'Número de referencia deber ser Servicios o Eventos'
END
END
Hola.
Te falta cerrar paracentesis en el primer IF
IF (@object_type in (13) and @transaction_type in ('A') debe ser: IF (@object_type in (13) and @transaction_type in ('A'))
ademas la variable esta mal expresada en el set @tipodocto tienes:
@listo_of_cols_val_tab_del es:
@list_of_cols_val_tab_del
Prueba y nos comentas
Saludos
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
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.