cancel
Showing results for 
Search instead for 
Did you mean: 

Busqueda Formateada

former_member263548
Participant
0 Kudos

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!

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member263548
Participant
0 Kudos

Gracias, pero no cambia el consecutivo.

Former Member
0 Kudos

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