Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8456

Re: Reporte de Factura de Proveedor vs Orden de Compra

$
0
0

Que tal Carlos, soy nuevo en este foro, espero este query sea lo que necesitas:

 

-- TABLA "RELACIÓN DE FACTURAS - ÓRDENES DE COMPRA

DECLARE @FACT AS TABLE(DocNum  INT, NumAtCard VARCHAR(100), DocDate DATE, BaseEntry INT, BaseType INT)

 

-- VISTA "FACTURAS - ÓRDENES DE COMPRA"

INSERT INTO @FACT

-- FACTURA - ÓRDEN DE COMPRA

SELECT DISTINCT T1.DocNum, T1.NumAtCard, T1.DocDate, T0.BaseEntry, T0.BaseType

FROM PCH1 T0

INNER JOIN OPCH T1 ON T0.DocEntry = T1.DocEntry

WHERE T0.BaseType = 22

 

UNION ALL

 

-- FACTURA - ENTRADA - ÓRDEN DE COMPRA

SELECT DISTINCT T1.DocNum, T1.NumAtCard, T1.DocDate, T2.BaseEntry, T2.BaseType

FROM PCH1 T0

INNER JOIN OPCH T1 ON T0.DocEntry = T1.DocEntry

INNER JOIN PDN1 T2 ON T0.BaseEntry = T2.DocEntry AND T0.BaseType = T2.ObjType

WHERE T2.BaseType = 22

 

-- VISTA PRINCIPAL

SELECT DISTINCT

-- DATOS DE ÓRDENES DE COMPRA

T0.DocNum [Doc SAP] ,T0.NumAtCard [Referencia] ,T0.DocDate [Fecha],

-- DATOS DE FACTURAS DE PROVEEDOR

T1.DocNum [Fact. SAP], T1.NumAtCard [Referencia], T1.DocDate [Fecha]

FROM OPOR T0

LEFT JOIN @FACT T1 ON T0.DocEntry = T1.BaseEntry AND T0.ObjType = T1.BaseType

WHERE T0.DocDate >= [%0] AND T0.DocDate <= [%1]

ORDER BY 1

 

Saludos,


Viewing all articles
Browse latest Browse all 8456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>