Skip to Content

Busqueda Formateada

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!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Feb 01, 2017 at 06:53 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 06, 2017 at 05:23 PM

    Gracias, pero no cambia el consecutivo.

    Add comment
    10|10000 characters needed characters exceeded