You are on page 1of 4

--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 @UserId2 = (SELECT SlpCode FROM OINV WHERE DocEntry =


@list_of_cols_val_tab_del)
--

SET @User3 = (Select T1.[USERID] FROM OINV T0 INNER JOIN OUSR T1 ON T0.[UserSign] = T1.
[USERID] Where CardCode=@CardCode)

If @Object_Type = '13' AND @transaction_type IN ('U')


BEGIN
DECLARE

@UserId2 SMALLINT,
@UserId SMALLINT

SET @UserId = (SELECT UserSign FROM OINV WHERE DocEntry =


@list_of_cols_val_tab_del)
SET @UserId2 = (SELECT UserSign2 FROM OINV WHERE DocEntry =
@list_of_cols_val_tab_del)

if (@UserId!= @UserId2)

begin
select @error = 1234
select @error_message='No se Permite Cambiar el eempleado de ventas
End
End

SELECT T0.[CardCode], T0.[CreateDate] FROM OCRD T0 WHERE T0.[CardType] = 'L' AND T0.
[CardCode] NOT LIKE '%B%'

CONVERT(SUBSTR(T0.[CardCode], FROM 2))as numero


SELECT

Substring ((MAX(T0.CardCode)),1,30) as integer

FROM

OCRD T0 WHERE T0.[CardType] = 'L' AND T0.[CardCode] NOT LIKE '%B%'

Excluye

SELECT

Cast ((Cast((Substring ((MAX(T0.CardCode)),2,15))as integer)+1) as Nvarchar(20))

FROM

OCRD T0 WHERE T0.[CardType] = 'L' AND T0.[CardCode] NOT LIKE '%B%'

Mo se como allar el mayor de la columna si son valores

Query numero automtico

Select 'L' +Cast (MAX(CAST(SUBSTRING(OCRD.CardCode,2,10) as numeric(10)))+1 as


nvarchar(10))item

from [Produccion_Prb].[dbo].[OCRD] OCRD

where OCRD.CardType = 'L' and

OCRD.cardcode BETWEEN 'L00000000000' AND 'L99999999999' and

OCRD.cardcode <> 'L800231021' AND

OCRD.cardcode <> 'L45678'

order by tem
If @transaction_type in ('U') and @object_type in ('13')
BEGIN
DECLARE
@SlpCode varchar(12),
@Pago_OV SMALLINT,
@Pago_SN SMALLINT

SET @ SlpCode = (Select SlpCode From OINV Where DocEntry=@list_of_cols_val_tab_del)


SET @Pago_OV = (Select GroupNum From OINV Where DocEntry= @list_of_cols_val_tab_del)
SET @Pago_SN = (Select GroupNum From OCRD Where CardCode=@CardCode)

IF (@Pago_OV != @Pago_SN) or (@Pago_OV != '-1')


BEGIN
SELECT @error = -600, @error_message= 'No se Permite Cambiar la Condicion de Pago'
END
END

Gracias por la ayuda Amigo. logre hacer los TNs con la informacion de ese Post. comparto
el codigo del TN:

IF @object_type=2 AND @transaction_type in ('A','U')

BEGIN

IF

(SELECT T0.CardType FROM OCRD T0 WHERE


T0.CardCode=@list_of_cols_val_tab_del ) 'S'

BEGIN

DECLARE @USER as Nvarchar (25)

DECLARE @CPAGO as Nvarchar (25)

DECLARE @LCREDITO Nvarchar (25)

SET @USER = (SELECT T0.userSign FROM OCRD T0 WHERE T0.CardCode =


@list_of_cols_val_tab_del)
SET @CPAGO = (SELECT T0.GroupNum FROM OCRD T0 WHERE T0.CardCode =
@list_of_cols_val_tab_del)

SET @LCREDITO = (SELECT T0.CreditLine FROM OCRD T0 WHERE T0.CardCode =


@list_of_cols_val_tab_del)

END

IF (@USER IN (1)) AND ((@CPAGO '-1') OR (@LCREDITO '0.000000'))

BEGIN

SET @error = 201

SET @error_message = 'No tiene autorizacion para establecer condicion de pago ni limite
de Credito -Feliz da!'

END

END

If @Object_Type = '13' AND @transaction_type IN ('U')


BEGIN
DECLARE

@UserId2 SMALLINT,
@UserId SMALLINT

SET @UserId = (SELECT UserSign FROM OINV WHERE DocEntry =


@list_of_cols_val_tab_del)
SET @UserId2 = (SELECT UserSign2 FROM OINV WHERE DocEntry =
@list_of_cols_val_tab_del)

if @UserId2 != 1 AND (@UserId!= @UserId2)

begin
SET @error = 1234
SET @error_message= 'No se puede cambiar el empleado del departamente
de ventas'
End
End

You might also like