Avalados por :

Guia para obter os números de documentos no SAP: Ordem de Venda, Entregas e Faturas

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

OLÁ FÓRUM SAP,

PRECISO DO SEU APOIO PARA OBTER O CICLO DE NÚMEROS DE DOCUMENTOS DE:

Ordem de Venda, Entregas e Faturas

Em qualquer caso de existir:

Ordem de Venda -> Entregas -> Faturas

Ordem de Venda -> Faturas


SÓ PRECISO DOS NÚMEROS, SEI QUE ESTÃO NO CAMPO DE COMENTÁRIOS DE CADA DOCUMENTO. MAS OS USUÁRIOS ESCREVEM MUITAS COISAS LÁ E É DIFÍCIL MOSTRAR ESSES CAMPOS EM TODO O TEXTO EXTRA.

DE ONDE POSSO OBTER ESSA CADEIA EM CADA CASO?

OBRIGADO

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

4 Respuestas

0
Cargando...

FELIPE BOM DIA,

PEÇO DESCULPAS EM RELAÇÃO A ESTE ASSUNTO QUANDO FAÇO UPLOAD DA MINHA FUNÇÃO NO SAP NO QUERY MANAGER, ELA EMITE ALGUNS ERROS.

ANEXO AQUI MEU QUERY PARA SEU APOIO, POR FAVOR, MUITO OBRIGADO

ALTERAR Função Numeros(@str varchar(200))

retorna varchar(100)

como começar

declarar

@conta tinyint

,@numeros varchar(100)

,@num int

definir @numeros = ''

definir @conta = 1

definir @num = 0

enquanto (@conta < 200)

começar

se substring(@str, @conta,1) em ('0','1','2','3','4','5','6','7','8','9')

definir @numeros = @numeros + substring(@str, @conta,1)

definir @conta=@conta+1

fim

retornar @numeros

fim

ir

Selecionar

distinto T0.DocNum como 'ENTREGAS',

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

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

Converter(char(10),t0.DocDate, 103)como 'DATA DE ENTREGA',

T0.Comments como 'COMENTÁRIOS',

T0.U_logentrega COMO 'LOGÍSTICA DE ENTREGA',

T0.U_fechaEmbarqueMHO COMO 'DATA DE EMBARQUE',

T0.U_noGuia COMO 'Nº. GUIA',

Caso T0.U_destino

quando '01' então 'EATON' quando '02' então 'FORT WAYNE' quando '03' então 'SHREVEPORT' quando '04' então 'MIAMI' quando '05' então 'MEXICO'

quando '06' então 'EDO.MEXICO' quando '07' então 'GUADALAJARA' quando '08' então 'SPRINGFIELD' quando '09' então 'MONTERREY' quando '10' então 'PUEBLA'

quando '100' então 'SPARTANBURG' quando '101' então 'TULARE' quando '102' então 'FT.LAUDERDALE' quando '103' então 'CRESTON' quando '104' então 'BURLINGTON'

quando '105' então 'ELGIN' quando '106' então 'LINIER BEAUCE' quando '107' então 'NINGBO' quando '108' então 'GRIFFIN' quando '109' então 'FAIRFAX'

quando '11' então 'VERNON HILLS' quando '110' então 'MOORESVILLE'

fim como 'DESTINO',

Caso T0.U_transportista

quando '00' então 'CLIENTE RETIRA NO ESCRITÓRIO'

quando '01' então 'CAMINHONETE MHO'

quando '02' então 'CAMINHONETE SFT'

quando '03' então 'CAMINHONETE Marin'

quando '04' então 'PACOTE EXPRESSO'

quando '05' então 'FRETES GDL-MERIDA'

quando '06' então 'EASO CONSOLIDADO'

quando '07' então 'TRANSPORTES CALAFIA'

quando '08' então 'TRANSPORTES CULIACAN'

quando '09' então 'TRANSPORTES 3 GUERRAS'

quando '10' então 'JULIAN DE OBREGON'

quando '11' então 'EASO MTY'

quando '12' então 'EASO GDL'

quando '13' então 'EASO MEX'

quando '14' então 'TRANSPORTES ALMEX'

quando '15' então 'DHL'

quando '16' então 'AEROMEXPRESS'

quando '17' então 'ESTAFETA'

quando '18' então 'TRANSP UNIDOS TAMPIQUENOS'

quando '19' então 'REDPACK'

quando '20' então 'TRANSP UNIDOS TAMPIQUENOS'

quando '21' então 'AGENTE ADUANEIRO'

quando '22' então 'INOVADORES'

quando '23' então 'CAMINHÃO COMPLETO'

quando '24' então 'ESTRELA BRANCA'

quando '25' então 'TRANSP MERCURIO'

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

Para incluirlo, você deve criar o código como uma função


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

Em seguida, adicione-o à sua consulta


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 

Saudações

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

Felipe,

Estou entrando em contato porque não consegui inserir seu código em minha consulta. Apenas preciso que o campo T0.Comments exiba o resultado da sua consulta, agradeço muito seu apoio.

Muito obrigado

Minha 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...

Olá

Experimente este código:


declare 
     @str  varchar(200)
    ,@cuenta tinyint
    ,@numeros varchar(100)
        
set @str='Baseado no pedido 1234 . comentário do usuário...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

Na variável @str, você deve inserir o comentário do documento.

Saudações

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?