Avalados por :

Guía para obtener los números de documentos en SAP: Orden de Venta, Entregas y Facturas

  • Creado 01/03/2024
  • Modificado 01/03/2024
  • 23 Vistas
0
Cargando...

HOLA FORO SAP,

NECESITO DE SU APOYO PARA CONTAR CON EL CICLO DE LOS NÚMEROS DE LOS DOCUMENTOS DE:

Orden de Venta, Entregas y Facturas

En cualquier caso de existir:

Orden de Venta -> Entregas -> Facturas

Orden de Venta -> Facturas


SOLO NECESITO LOS NÚMEROS, SÉ QUE ESTÁN EN EL CAMPO COMENTARIOS DE CADA DOCUMENTO. PERO LOS USUARIOS ESCRIBEN MUCHAS COSAS AHÍ Y ES DIFÍCIL MOSTRAR ESOS CAMPOS POR TODO EL TEXTO EXTRA.

¿DE DÓNDE PODRÍA OBTENER ESA CADENA EN CADA CASO?

GRACIAS

Pedro Pascal
Se unió el 07/03/2018
Pinterest
Telegram
Linkedin
Whatsapp

4 Respuestas

0
Cargando...

FELIPE BUEN DIA,

UNA DISCULPA CON RESPECTO A ESTE TEMA CUANDO SUBO MI FUNCION A SAP EN QUERY MANAGER ME EMITE ALGUNOS ERRORES.

TE ADJUNTO MI QUERY PARA TU APOYO POR FAVOR, MUCHAS GRACIAS

ALTER Function Numeros(@str varchar(200))

returns varchar(100)

as begin

declare

@cuenta tinyint

,@numeros varchar(100)

,@num int

set @numeros = ''

set @cuenta = 1

set @num = 0

while (@cuenta < 200)

begin

if substring(@str, @cuenta,1) in ('0','1','2','3','4','5','6','7','8','9')

set @numeros = @numeros + substring(@str, @cuenta,1)

set @cuenta=@cuenta+1

end

return @numeros

end

go

Select

distinct T0.DocNum as 'ENTREGAS',

(dbo.Numeros(SUBSTRING(T0.Comments,(CHARINDEX('Pedidos',T0.Comments)+19),5))) +

(dbo.Numeros(SUBSTRING(T0.Comments,(CHARINDEX('Sales',T0.Comments)+13),5))) as 'PEDIDOS',

Convert(char(10),t0.DocDate, 103)as 'FECHA ENTREGA',

T0.Comments as 'COMENTARIOS',

T0.U_logentrega AS 'LOGISTICA ENTREGA',

T0.U_fechaEmbarqueMHO AS 'FECHA EMBARQUE',

T0.U_noGuia AS 'NO. GUIA',

Case T0.U_destino

when '01' then 'EATON' when '02' then 'FORT WAYNE' when '03' then 'SHREVEPORT' when '04' then 'MIAMI' when '05' then 'MEXICO'

when '06' then 'EDO.MEXICO' when '07' then 'GUADALAJARA' when '08' then 'SPRINGFIELD' when '09' then 'MONTERREY' when '10' then 'PUEBLA'

when '100' then 'SPARTANBURG' when '101' then 'TULARE' when '102' then 'FT.LAUDERDALE' when '103' then 'CRESTON' when '104' then 'BURLINGTON'

when '105' then 'ELGIN' when '106' then 'LINIER BEAUCE' when '107' then 'NINGBO' when '108' then 'GRIFFIN' when '109' then 'FAIRFAX'

when '11' then 'VERNON HILLS' when '110' then 'MOORESVILLE'

end as 'DESTINO',

Case T0.U_transportista

when '00' then 'CLIENTE RECOJE EN OFNA'

when '01' then 'CAMIONETA MHO'

when '02' then 'CAMIONETA SFT'

when '03' then 'CAMIONETA Marin'

when '04' then 'PAQ. EXPRESS'

when '05' then 'FLETES GDL-MERIDA'

when '06' then 'EASO CONSOLIDADO'

when '07' then 'TRANSPORTES CALAFIA'

when '08' then 'TRANSPORTES CULIACAN'

when '09' then 'TRANSPORTES 3 GUERRAS'

when '10' then 'JULIAN DE OBREGON'

when '11' then 'EASO MTY'

when '12' then 'EASO GDL'

when '13' then 'EASO MEX'

when '14' then 'TRANSPORTES ALMEX'

when '15' then 'DHL'

when '16' then 'AEROMEXPRESS'

when '17' then 'ESTAFETA'

when '18' then 'TRANSP UNIDOS TAMPIQUENOS'

when '19' then 'REDPACK'

when '20' then 'TRANSP UNIDOS TAMPIQUENOS'

when '21' then 'AGENTE ADUANAL'

when '22' then 'INNOVATIVOS'

when '23' then 'CAMION COMPLETO'

when '24' then 'ESTRELLA BLANCA'

when '25' then 'TRANSP MERCURIO'

<
Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

Para incluirlo debes crear el código como función


create function Devolver_numeros(@str varchar(200))
returns varchar(100)
as begin
    declare 
         @cuenta tinyint
        ,@numeros varchar(100)

    set @numeros=''
    set @cuenta=1

    while (@cuenta < 200)
    begin
        if substring(@str, @cuenta,1) in ('0','1','2','3','4','5','6','7','8','9')
        set @numeros = @numeros + substring(@str, @cuenta,1)

        set @cuenta=@cuenta+1
    end

    return @numeros
end
go

Luego agregarlo a tu query


Select distinct T0.DocNum as 'FACTURA',dbo.Devolver_numeros(T0.Comments) as 'No Documentos',Convert(char(10),t0.DocDate, 103)as 'FECHA FACTURA'
from OINV T0 

Saludos

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

Felipe,

Te consulto porque no he logrado insertar tu código en mi consulta. Solo necesito que el campo de T0.Comments muestre el resultado de tu consulta, agradecería mucho tu apoyo.

Mil Gracias

Mi consulta:

Select distinct T0.DocNum as 'FACTURA',T0.Comments as 'No Documentos',Convert(char(10),t0.DocDate, 103)as 'FECHA FACTURA'

from OINV T0

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

Buenas

Prueba este código:


declare 
     @str  varchar(200)
    ,@cuenta tinyint
    ,@numeros varchar(100)
        
set @str='Basado en pedido 1234 . comentario del usuario...etc'
set @numeros=''
set @cuenta=1

while (@cuenta < 200)
begin
    if substring(@str, @cuenta,1) in ('0','1','2','3','4','5','6','7','8','9')
    set @numeros = @numeros + substring(@str, @cuenta,1)

    set @cuenta=@cuenta+1
end

select @numeros

En la variable @str debes colocar el comentario del documento.

Saludos

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019

contacto@primeinstitute.com

(+51) 1641 9379
(+57) 1489 6964

© 2024 Copyright. Todos los derechos reservados.

Desarrollado por Prime Institute

¡Hola! Soy Diana, asesora académica de Prime Institute, indícame en que curso estas interesado, saludos!
Hola ¿Puedo ayudarte?