Skip to Content
avatar image
Former Member

Consulta formatada localização de Documento

Pessoal bom dia.

Preciso colocar essa consulta abaixo no sistema para consultar documentos, porem quando parametrizo a clausula where a consulta não funciona mais, alguem poderia me ajudar com essa ou com alguma outra consulta que tenham para localizar documentos no sistema:

SELECT 'NF Entrada', DocEntry, DocDate, Serial FROM OPCH WHERE Serial='4281' union all /* nf entrada*/ SELECT 'Devoluções', DocEntry, DocDate, Serial FROM ORDN WHERE Serial='4281' union all /*Devoluções*/ SELECT 'Dev. NF Saida', DocEntry, DocDate, Serial FROM ORIN WHERE Serial='4281' union all /*Devolução Nf Saída*/ SELECT 'Recebimento', DocEntry, DocDate, Serial FROM OPDN WHERE Serial='4281' union all /*Recebimento de mercadorias*/ SELECT 'NF Saida', DocEntry, DocDate, Serial FROM OINV WHERE Serial='4281' union all /* nf saida*/ SELECT 'Entrega', DocEntry, DocDate, Serial FROM ODLN WHERE Serial='4281' union all /*Entraga*/ SELECT 'Dev. NF Entrada', DocEntry, DocDate, Serial FROM ORPC WHERE Serial='4281' union all /*Devolução Nf Entrada*/ SELECT 'Devoluções de mercadoria', DocEntry, DocDate, Serial FROM ORPD WHERE Serial='4281' /*Devolução de Mercadoria*/

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 23, 2017 at 06:53 PM

    Boa tarde.

    Declare uma variavel antes, e utilize ela na sua consulta, lembrando que serial é int

    O primeiro /* T0.Serial */ é pra enganar o SAP, assim ele sabe que é esse campo que deve ser solicitado.

    DECLARE @SERIAL INT
    SET @SERIAL = /* T0.SERIAL */ [%0]
    
    SELECT 'NF Entrada', T0.DocEntry, T0.DocDate, T0.Serial FROM OPCH T0 WHERE T0.Serial=@SERIAL
    union all 
    SELECT 'Devoluções', T0.DocEntry, T0.DocDate, T0.Serial FROM ORDN T0 WHERE T0.Serial=@SERIAL
    union all 
    SELECT 'Dev. NF Saida', T0.DocEntry, T0.DocDate, T0.Serial FROM ORIN T0 WHERE T0.Serial=@SERIAL
    union all 
    SELECT 'Recebimento', T0.DocEntry, T0.DocDate, T0.Serial FROM OPDN T0 WHERE T0.Serial=@SERIAL
    union all 
    SELECT 'NF Saida', T0.DocEntry, T0.DocDate, T0.Serial FROM OINV T0 WHERE T0.Serial=@SERIAL
    union all 
    SELECT 'Entrega', T0.DocEntry, T0.DocDate, T0.Serial FROM ODLN T0 WHERE T0.Serial=@SERIAL
    union all 
    SELECT 'Dev. NF Entrada', T0.DocEntry, T0.DocDate, T0.Serial FROM ORPC T0 WHERE T0.Serial=@SERIAL
    union all 
    SELECT 'Devoluções de mercadoria', T0.DocEntry, T0.DocDate, T0.Serial FROM ORPD T0 WHERE T0.Serial=@SERIAL
    
    

    []'s

    Fabio

    SAP 9.1 PL11 / SAP 9.2 PL5 (test)

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 23, 2017 at 07:05 PM

    Muito bom mesmo obrigado!

    Add comment
    10|10000 characters needed characters exceeded