on 06-17-2011 8:55 PM
Hola a todos, me gustaria bloquear si un usuario en especifico me cambia la condicion de pago en la Orden de Venta, hice este transaction pero cuando le meto la validacion del usersign no entra, y si se lo quito tambien me permite cambiar la condicion, no veo el error.
Declare @cond_cli varchar
Declare @cond_doc varchar
Declare @CodCli int
Declare @UserId int
If (@Object_Type = '17' and @transaction_type in ('A','U'))
Begin
Set @CodCli = (Select CardCode From ORDR Where DocEntry=@list_of_cols_val_tab_del)
Set @cond_cli = (Select GroupNum From OCRD Where CardCode=@CodCli)
Set @cond_doc = (Select GroupNum From ORDR Where DocEntry= @list_of_cols_val_tab_del)
Set @UserId = (select UserSign2 from ORDR where DocEntry = @list_of_cols_val_tab_del)
IF ((@cond_cli != @cond_doc) and @UserId in (50))
begin
select @error = 1234
select @error_message='No se Permite Cambiar la Condicion de Pago'
End
End
Alguien me puede apoyar?
Saludos
Alessandro.
Hola Alessandro
Prueba el SP_TN de esta manera
-- VALIDA CONDICION DE PAGO
If @Object_Type = '17' AND @transaction_type IN ('A','U')
BEGIN
DECLARE
@CardCode varchar(12),
@Pago_OV SMALLINT,
@Pago_SN SMALLINT,
@UserId SMALLINT
SET @CardCode = (Select CardCode From ORDR Where DocEntry=@list_of_cols_val_tab_del)
SET @Pago_OV = (Select GroupNum From ORDR Where DocEntry= @list_of_cols_val_tab_del)
SET @Pago_SN = (Select GroupNum From OCRD Where CardCode=@CardCode)
SET @UserId = (select UserSign from ORDR where DocEntry = @list_of_cols_val_tab_del)
IF ((@Pago_OV != @Pago_SN)AND @UserId = 50)
BEGIN
SELECT @error = -600, @error_message= 'No se Permite Cambiar la Condicion de Pago'
END
END
Atte.
Felipe Loyola
Edited by: Floyola on Jun 19, 2011 4:37 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mauricio,
Yo tengo SAP B1 2007A SP 00 PL 49 y exactamente no existe el campo UserSing2 en OCRD y ACRD
Pero si existe en las tablas de documentos OPCH,OINV...etc. Aunque no aparecen en el generador de consutas pero si estan
Alessandro, la idea del TN es que este usuario especifico no modifique o que ningun usuario pueda modificar o crear el docuemnto con un medio de pago distinto al que esta en el SN?
Slds
Edited by: Floyola on Jun 20, 2011 12:13 PM
Q tal asi?
if @object_type in ('17') and @transaction_type in ('U')
begin
declare @user as int
set @user =(select usersign2 from ordr where docentry =@list_of_cols_.,,,,)
if (select groupnum from ordr where docentry=@list_of_cols_,,,,,,,,) != (select groupnum from ADOC where objtype=17 and
docentry=@list_of_cols_val....) AND @user in (3,5,2)--- el numero correspondiente al userId de la OUSR que quieres bloquear
begin
select @error = 1234
select @error_message='No se Permite Cambiar la Condicion de Pago'
End
End
mmm
Como te decia, prueba cambiando el UserSign de mi validacion
-- VALIDA CONDICION DE PAGO
If @Object_Type = '17' AND @transaction_type IN ('A','U')
BEGIN
DECLARE
@CardCode varchar(12),
@Pago_OV SMALLINT,
@Pago_SN SMALLINT,
@UserId SMALLINT
SET @CardCode = (SELECT CardCode FROM ORDR WHERE DocEntry=@list_of_cols_val_tab_del)
SET @Pago_OV = (SELECT GroupNum FROM ORDR WHERE DocEntry= @list_of_cols_val_tab_del)
SET @Pago_SN = (SELECT GroupNum FROM OCRD WHERE CardCode=@CardCode)
SET @UserId = (SELECT UserSign2 FROM ORDR WHERE DocEntry = @list_of_cols_val_tab_del)
IF ((@Pago_OV != @Pago_SN) AND @UserId IN ('X','Y','Z'))
BEGIN
SELECT @error = -600, @error_message= 'No se Permite Cambiar la Condicion de Pago'
END
END
Espero sirva
Atte.
FLR
Ok asi lo probe con las ofertas a clientes
solo cambia el 23 por el numero 17 y la OQUT por la ORDR
if @transaction_type in ('U') and @object_type in ('23')
begin
declare @user as int
declare @cp1 as int
declare @cp2 as int
set @user =(select usersign from oqut where docentry =@list_of_cols_val_tab_del)
set @cp1=(select groupnum from OQUT where docentry=@list_of_cols_val_tab_del)
set @cp2= (select GroupNum from ADOC where objtype=23 and
docentry=@list_of_cols_val_tab_del and LogInstanc in (select MAX(LogInstanc-1)from ADOC where DocEntry =@list_of_cols_val_tab_del) )
if (@user = 1) and @cp1 != @cp2--- el numero correspondiente al userId de la OUSR que quieres bloquear
begin
select @error = 1234
select @error_message='No se Permite Cambiar la Condicion de Pago'
End
End
Mauricio Te funciono a ti en cotizacion? Ya que Copie tu codigo para el modulo de cotizaciones y no me funciono.
Le cambie las tablas y el objectype para la ORDR y tampoco me funcionó.
If @transaction_type in ('A','U') and @object_type in ('17')
begin
declare @user as int
declare @cp1 as int
declare @cp2 as int
set @user =(select UserSign from ORDR where docentry =@list_of_cols_val_tab_del)
set @cp1=(select groupnum from ORDR where docentry=@list_of_cols_val_tab_del)
set @cp2= (select GroupNum from ADOC where objtype=17 and docentry=@list_of_cols_val_tab_del and LogInstanc in (select MAX(LogInstanc-1)from ADOC where DocEntry =@list_of_cols_val_tab_del) )
if (@user = 50,126) and @cp1 != @cp2
begin
select @error = 1234
select @error_message='No se Permite Cambiar la Condicion de Pago'
End
End
Tambien le cambie a UserSign2 y nada. O_o
Saludos
Alessandro.
Claro Mauricio, El ultimo que probe es el tuyo,
If @transaction_type in ('A','U') and @object_type in ('17')
begin
declare @user as int
declare @cp1 as int
declare @cp2 as int
set @user =(select UserSign2 from ORDR where docentry =@list_of_cols_val_tab_del)
set @cp1=(select groupnum from ORDR where docentry=@list_of_cols_val_tab_del)
set @cp2= (select GroupNum from ADOC where objtype = '17' and docentry=@list_of_cols_val_tab_del and LogInstanc in (select MAX(LogInstanc-1)from ADOC
where DocEntry =@list_of_cols_val_tab_del) )
if (@user = 50) and @cp1 != @cp2
begin
select @error = 1234
select @error_message='No se Permite Cambiar la Condicion de Pago'
End
End
Saludos
Alessandro.
Creo que a mi me funciona porque en el max (loginstac) yo no tengo mas documentos (Facturas, entregas, etc) que afecten la ADOC
Quizas ya en productivo como es tu caso, necesitas un filtro mas en la ultima parte
Intenta asi
If @transaction_type in ('A','U') and @object_type in ('17')
begin
declare @user as int
declare @cp1 as int
declare @cp2 as int
set @user =(select UserSign2 from ORDR where docentry =@list_of_cols_val_tab_del)
set @cp1=(select groupnum from ORDR where docentry=@list_of_cols_val_tab_del)
set @cp2= (select GroupNum from ADOC where objtype = '17' and docentry=@list_of_cols_val_tab_del
and LogInstanc in (select MAX(LogInstanc-1)from ADOC where objtype = '17' AND DocEntry =@list_of_cols_val_tab_del) )
if (@user = 50) and @cp1 != @cp2
begin
select @error = 1234
select @error_message='No se Permite Cambiar la Condicion de Pago'
End
End
www.charlie-colop.com.mx/Condiciones_SAP.jpg
No entiendo por que me deja actualizar, como que no toma los parametros del usersign.
Saludos
Alessandro
Alessandro prueba este codigo
-- VALIDA CONDICION DE PAGO EN ORDEN DE VENTA
If @Object_Type = '17' AND @transaction_type IN ('U')
BEGIN
DECLARE
@CardCode varchar(12),
@Pago_OV SMALLINT,
@Pago_SN SMALLINT,
@UserId SMALLINT
SET @CardCode = (Select CardCode From ORDR Where DocEntry=@list_of_cols_val_tab_del)
SET @Pago_OV = (Select GroupNum From ORDR Where DocEntry= @list_of_cols_val_tab_del)
SET @Pago_SN = (Select GroupNum From OCRD Where CardCode=@CardCode)
SET @UserId = (select UserSign2 From ADOC Where Docentry = @list_of_cols_val_tab_del AND ObjType = @object_type
AND LogInstanc = (SELECT TOP 1 LogInstanc-1 FROM ADOC WITH(NOLOCK) WHERE DocEntry=@list_of_cols_val_tab_del AND ObjType=@object_type ORDER BY LogInstanc DESC))
IF (@UserId = 4) AND @Pago_OV != @Pago_SN
BEGIN
SELECT @error = -600, @error_message= 'No se Permite Cambiar la Condicion de Pago'
END
END
Saludos
Mauricio, exactamente como lo pusiste lo inserte en el sql, no me funciono o_O?
Floyola, meti el que pusiste y tampoco
Creo que No esta jalando lo del usersign por que si se lo quito si funciona, pero la valicacion del usuario es lo importante
Quitado el usersign si bloquea:
<a href="http://www.charlie-colop.com.mx/condicion.jpg">http://www.charlie-colop.com.mx/condicion.jpg</a>
If @Object_Type = '17' AND @transaction_type = 'U'
BEGIN
DECLARE
@CardCode varchar(12),
@Pago_OV SMALLINT,
@Pago_SN SMALLINT
SET @CardCode = (Select CardCode From ORDR Where DocEntry=@list_of_cols_val_tab_del)
SET @Pago_OV = (Select GroupNum From ORDR Where DocEntry= @list_of_cols_val_tab_del)
SET @Pago_SN = (Select GroupNum From OCRD Where CardCode=@CardCode)
IF @Pago_OV != @Pago_SN
BEGIN
SELECT @error = -600, @error_message= 'No se Permite Cambiar la Condicion de Pago'
END
END
Saludos
Alessandro
Alessandro ese codigo me funciono aqui en la base DEMO
No entiendo porque no te esta funcionando...estas seguro que los usuarios son los correctos a los INTERNAL_K que estas bloquenado
En mi ejemplo use al Usuario de Ventas "4" y efectivamente me bloqueo con solo colocar la condicion
IF (@UserId = 4) me bloqueo automaticamente el usuario para modificar
Atte.
Felipe Loyola
Pues si es algo del diablo porq a mi me funciona asi para cualquier documento, si quieres lo revisamos remotamente con teamviewer
If @transaction_type in ('A','U') and @object_type in ('17')
begin
declare @user as int
declare @cp1 as int
declare @cp2 as int
set @user =(select UserSign2 from ORDR where docentry =@list_of_cols_val_tab_del)
--en version 88 es usersign2, en 2007 seria usersign de la ADOC (tu comentaste que tienes 88)
set @cp1=(select groupnum from ORDR where docentry=@list_of_cols_val_tab_del)
set @cp2= (select GroupNum from ADOC where objtype = '17' and docentry=@list_of_cols_val_tab_del
and LogInstanc in (select MAX(LogInstanc-1)from ADOC where objtype = '17' AND DocEntry =@list_of_cols_val_tab_del) )
if (@user = 50) and @cp1 != @cp2
begin
select @error = 1234
select @error_message='No se Permite Cambiar la Condicion de Pago'
End
End
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
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.