on 01-26-2011 2:36 PM
Estimados amigos buceando un poco por el foro he visto que si se puede actualizar campo de usuario. bueno me he guiado de algunas consulta que han hecho pero no tengo suerte con lo que quier ohacer.
Mi caso es el siguiente: deseo que al crear una nota de credito con la serie 000 se actualize un campo de usuario en la factura que pase del estado 1 al 2 use este codigo pero no actualiza quizas me puedan ayudar y ver que pasa por que no me actualiza el campo que deseo
IF @TRANSACTION_TYPE IN ('A','U') AND @OBJECT_TYPE IN ('14')
BEGIN
DECLARE @TDOCORI nvarchar(2)
DECLARE @TDOCSER NVARCHAR(3)
DECLARE @TDOCCOR NVARCHAR (7)
--VALIDACION QUE ACTUALIZA EL CAMPO DE ESTADO DE LA FACTURA SI ESTA SE ANULA CON UNA NOTA DE CREDITO
BEGIN
SELECT
@CLIENTE = CONVERT(VARCHAR,CARDCODE),
@TDOCORI = CONVERT(VARCHAR,U_BPP_MDTO),
@TDOCSER = CONVERT(VARCHAR,U_BPP_MDSO),
@TDOCCOR = CONVERT(VARCHAR,U_BPP_MDCO)
FROM
ORIN
WHERE
DOCENTRY=@LIST_OF_COLS_VAL_TAB_DEL AND U_BPP_MDSD = '000'
UPDATE OINV SET U_QA_STA = 2
WHERE
CARDCODE = @CLIENTE
AND U_BPP_MDTD = @TDOCORI
AND U_BPP_MDSD = @TDOCSER
AND U_BPP_MDCD = @TDOCCOR
AND DOCENTRY=@LIST_OF_COLS_VAL_TAB_DEL
END
END
Buenas
Prueba esta validacion y nos cuentas como te va.
--VALIDACION QUE ACTUALIZA EL CAMPO DE ESTADO DE LA FACTURA SI ESTA SE ANULA CON UNA NOTA DE CREDITO
IF @TRANSACTION_TYPE IN ('U') AND @OBJECT_TYPE IN ('13')
BEGIN
DECLARE @Doc as Nvarchar(10)
SELECT @Doc = (SELECT DocEntry FROM OINV WHERE DocEntry = @list_of_cols_val_tab_del)
DECLARE @STATUS as Nvarchar(10)
SELECT @STATUS = (SELECT COUNT(T1.TargetType)
FROM OINV T0
INNER JOIN INV1 T1 ON T1.DocEntry = T0.DocEntry
WHERE T1.TargetType = '-1' AND T0.DocEntry = @list_of_cols_val_tab_del)
DECLARE @LINE as Nvarchar(10)
SELECT @LINE = SELECT COUNT(T1.LineNum)
FROM OINV T0
INNER JOIN INV1 T1 ON T1.DocEntry = T0.DocEntry
WHERE T0.DocEntry = @list_of_cols_val_tab_del)
IF (@Line != @STATUS)
BEGIN
UPDATE OINV SET U_QA_STA = '2'
WHERE DocEntry = @Doc
END
END
Esto en base a que el campo TargetType del OINV cambia de -1 al 14 cuando una factura se copia a una nota de credito. Entonces el numero de lineas debe ser igual al numero de TargetType que tienen -1 cuando la factura esta OK, si se le aplica una NC a esa factura, las lineas que se copien tendran un TargetType distinto y no se contaran, haciendo que se dispare la igualdad y actualize el campo de usuario. bueno esa es la idea.
Pruebalo y nos cuentas
Saludos
FLR
Edited by: Floyola on Jan 26, 2011 5:21 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Buenas
Prueba este SP y me cuentas que tal
Una consulta, que almacenas en el campo U_BPP_MDSO , no te sirve el campo ORIN,Series para este SP?
IF @TRANSACTION_TYPE IN ('A') AND @OBJECT_TYPE IN ('14')
BEGIN
DECLARE @Serie as Nvarchar(25)
SELECT @Serie = (CONVERT(VARCHAR,U_BPP_MDSO) FROM ORIN WHERE DocEntry = @list_of_cols_val_tab_del)
DECLARE @DocFact as Nvarchar(10)
SELECT @DocFact = (SELECT DISTINCT T1.BaseEntry
FROM ORIN T0
INNER JOIN RIN1 T1 ON T1.DocEntry = T0.DocEntry
WHERE T0.DocEntry = @list_of_cols_val_tab_del)
IF @Serie = '000' AND @DocFact is not null
BEGIN
UPDATE OINV SET U_QA_STA = '2'
WHERE DocEntry = @DocFact
END
END
Saludos
FLR
Edited by: Floyola on Feb 2, 2011 5:37 PM
Buenas
revisa[Note 1320484 - Business One - Stored Procedures].
Esta nota dice literalmente:
The functionalities of both SBO_SP_PostTransactionNotice and SBO_SP_TransactionNotification are the same, the only differences being when they are triggered and the ability to use the '@error' functionality of SBO_SP_TransactionNotification to rollback transactions. SBO_SP_PostTransactionNotice can only be triggered at the end of an action (transaction committed), whereas SBO_SP_TransactionNotification could be triggered at the beginning, middle or end of an action. It is preferable to use SBO_SP_PostTransactionNotice - although as this occurs after the transaction, the '@error' rollback functionality described in note 1305742 can not be used
Un saludo.
Agustí
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
12 | |
11 | |
6 | |
6 | |
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.