on 10-16-2015 3:41 PM
Buenos dias, tengo un SP el cual me controla de que si un articulo esta bloqueado en el datos maestro de articulo al realizar una cotizacion no permita crear el documento, obligando a los asesores a buscar un articulo alternativo, sin embargo quisiera saber si conocen alguna manera en que cuando se dispare el SP el mensaje que arroje indique el item que presenta el bloqueo, ya que si hubieran muchos articulos se tendria que entrar a revisar cual presentan esta caracteristica.
El SP que estoy utilizando es el siguiente.
----------------------------------------------ARTICULO BLOQUEADO----------------------------------------------------
if @object_type in ('23') and @transaction_type in ('A','U')
begin
IF(select count(*)
FROM OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry=T1.DocEntry LEFT JOIN OITW T2 ON T1.ItemCode=T2.ItemCode
WHERE ((T2.Locked='Y' AND T2.WhsCode=T1.WhsCode) AND (T0.UserSign2 not in ('5','198')) AND @list_of_cols_val_tab_del = T0.DocEntry))>0
Begin
set @error = 10
set @error_message = '***SP BLOQUEO VENTAS:El articulo se encuentra bloqueado para esta bodega"'
END
END
Quedaria muy agradecido si me pudieran dar ideas al respecto, quedo atento y agradezco su colaboración.
Prueba el siguiente código
if @object_type in ('23') and @transaction_type in ('A','U')
begin
declare @item nvarchar(20)
set @item=(select top 1 T1.ItemCode
FROM OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry=T1.DocEntry LEFT JOIN OITW T2 ON T1.ItemCode=T2.ItemCode
WHERE ((T2.Locked='Y' AND T2.WhsCode=T1.WhsCode) AND (T0.UserSign2 not in ('5','198')) AND @list_of_cols_val_tab_del = T0.DocEntry)
if @item is not null
Begin
set @error = 10
set @error_message = '***SP BLOQUEO VENTAS:El articulo '+ @item +' se encuentra bloqueado para esta bodega"'
END
END
Saludos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola Andres,
En el partner para el que trabajo se que para un cliente que solicito algo similar lo que hicieron fue encerrar la consulta del SP en una variable, le hicieron un SELECT TOP 1 y al final el mensaje de error le sumaban la variable para que indicara el articulo en cuestión.
Lo único es que va a mostrar uno por uno, es decir si el documento tiene varias lineas y varias presentan inconsistencias, muestra una por una.
Espero sea de tu ayuda, que tengas buen día
Slds,
IFV
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 | |
11 | |
11 | |
6 | |
6 | |
5 | |
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.