Skip to Content
0

Busqueda Formateada

Jan 31, 2017 at 09:46 PM

45

avatar image

Buenas tardes, estoy tratando de hacer una búsqueda formateada para armar un código según el grupo + UDF + consecutivo pero no lo logro, el script que tengo es el siguiente:

declare @type char(2)

set @type= (Select case $[OITM.ItmsGrpCod] when 122 then 'iCF' when 102 then 'GO' when 103 then 'iWA' else '' end)

declare @subgrupo char(2)

set @subgrupo= (Select case $[OITM.U_Codigo] when '101' then 'CH' when '102' then 'CO' else '' end )

Select

@type+@subgrupo+isnull(right(str(max(substring(i.ItemCode,4,3))+001),3),'001') From OITM i

Where

i.ItemCode like @type+'[0-9][0-9][0-9]' AND

i.ItemCode like @subgrupo+'[0-9][0-9][0-9]'

Agradezco la ayuda!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Taseeb Saeed Feb 01, 2017 at 06:53 AM
0

Dear Oscar,

I have done it for you please try it

Declare @type char (2)
Declare @subgrupo char (2)


SET @type = ''
SET @subgrupo = ''


IF $[OITM.ItmsGrpCod] = 122 
SET @type =  'iCF'  
IF $[OITM.ItmsGrpCod] = 102
SET @type =  'GO'  
IF $[OITM.ItmsGrpCod] = 103
SET @type =  'iWA'  




IF $[OITM.U_Code] = '101' 
SET @subgrupo = 'CH'
IF $[OITM.U_Code] = '102' 
SET @subgrupo = 'CO'




Select


@Type + @subgrupo + isnull (right (str (max (substring (i.ItemCode, 4,3)) + 001), 3), '001') From OITM i


Where


I.ItemCode like @type + '[0-9] [0-9] [0-9]' AND


I.ItemCode like @subgrupo + '[0-9] [0-9] [0-9]'

Thanks

Engr. Taseeb Saeed

Share
10 |10000 characters needed characters left characters exceeded
Oscar Murillo Feb 06, 2017 at 05:23 PM
0

Gracias, pero no cambia el consecutivo.

Share
10 |10000 characters needed characters left characters exceeded