@Willy_Caldero
Buenos Tardes
Ing Willy le doy la gracias por las sugerencias dadas realice la consultas como me lo explico y y la misa dio resultado exitosos. a continuación le muestro como realice la consulta.
SELECT DISTINCT T0.[customer], T0.[custmrName],
T0.[itemCode], T0.[itemName],T0.[internalSN],
T1.[ItemCode], T1.[ItemName], /*T2.DocAbs,*/
/*SUM(T1.[Delivered]-T1.[Returned])*/
SUM(T4.[Quantity]) AS CANTIDAD,/*T4.[GrossBuyPr]*/
T4.[StockPrice] AS COSTO, /*SUM(T4.[GPTtlBasPr])*/
SUM(T4.[Quantity])*(T4.[StockPrice]) AS 'COSTO TOTAL'
FROM [dbo].[OSCL] T0
INNER JOIN SCL2 T1 ON T0.[callID] = T1.[SrcvCallID]
INNER JOIN SCL4 T2 ON T0.[callID] = T2.[SrcvCallID]
INNER JOIN ODLN T3 ON T2.[DocAbs]=T3.[DocNum] AND T2.[Object] ='15'
INNER JOIN DLN1 T4 ON T3.[DocEntry] = T4.[DocEntry]
and T1.[ItemCode]=T4.[ItemCode]
WHERE T0.[createDate] >=[%3] AND T0.[createDate] <=[%4]
GROUP BY T0.[customer], T0.[custmrName],
T0.[itemCode], T0.[itemName], T0.[internalSN],
T1.[ItemCode], T1.[ItemName], /*T2.[DocAbs],*/
/*T4.[GrossBuyPr]*/ T4.[StockPrice]
UNION ALL
SELECT DISTINCT T0.[customer], T0.[custmrName],
T0.[itemCode], T0.[itemName],T0.[internalSN],
T1.[ItemCode], T1.[ItemName], /*T2.DocAbs,*/
/*-SUM(T1.[Delivered]-T1.[Returned])*/
-SUM(T4.[Quantity]) AS CANTIDAD,
/*-T4.[GrossBuyPr]*/
-T4.[StockPrice] AS COSTO,
/*-SUM(T4.[GPTtlBasPr])*/ -
-SUM(T4.[Quantity])*(T4.[StockPrice]) AS 'COSTO TOTAL'
FROM [dbo].[OSCL] T0
INNER JOIN SCL2 T1 ON T0.[callID] = T1.[SrcvCallID]
INNER JOIN SCL4 T2 ON T0.[callID] = T2.[SrcvCallID]
INNER JOIN ORDN T3 ON T2.[DocAbs]=T3.[DocNum] AND T2.[Object] ='16'
INNER JOIN RDN1 T4 ON T3.[DocEntry] = T4.[DocEntry]
and T1.[ItemCode]=T4.[ItemCode]
WHERE T0.[createDate] >=[%3] AND T0.[createDate] <=[%4]
GROUP BY T0.[customer], T0.[custmrName], T0.[itemCode], T0.[itemName],
T0.[internalSN],T1.[ItemCode], T1.[ItemName], /*T2.[DocAbs],*/ /*T4.[GrossBuyPr]*/ /*T4.[GPTtlBasPr]*/
T4.[StockPrice] ORDER BY 1
Para lo de la factura por medio de las llamadas de servicio haría la misma consulta solo cambiando las Tablas y campo.
Los campos que están comentados dentro de la consulta fueron los campos que cambio como me lo sugerido
Sin mas por el momento y esperada de sus comentario