Buen dia tengo un problema para generar una consulta de pagos resividos lo que ocupo obtener es el numero de documento electronico del pago resivido, he conseguido obtener el numero electronico pero es el de factura de deudores el cual por el momento no me interesa si me pudieran orientar estaria muy agradecido les comparto el query que llevo hasta el momento
SELECT DISTINCT
T0.[DocNum] as 'Pago'
,T0.[DocDate]
,T0.[CardName]
,stuff((
SELECT REPLACE( T14.[DocNum],'DocNum','' ),' , '
FROM
[dbo].[ORCT] T10 INNER JOIN RCT2 T11 ON T10.[DocEntry] = T11.[DocNum]
LEFT JOIN OINV T14 ON T11. [DocEntry] = T14. [DocEntry] AND T11.[InvType] = T14.ObjType
WHERE
T10.[DocNum]=T0.[DocNum]
FOR XML PATH ('')
), 1, 0, '') FOLIO
,(SELECT DISTINCT T22.[ReportID] FROM RCT2 T20 INNER JOIN ORCT T21 ON T20.[DocNum] = T21.[DocEntry], ECM2 T22 WHERE T21.[DocNum]=T0.[DocNum] AND T22.[AbsEntry]=T9.[AbsEntry]) NoDocumentoElectronico
,CASE T0.[U_B1SYS_PmntMethod]
WHEN 03 THEN 'Transferencia'
END 'Metodo de Pago'
,T0.[CardCode]
FROM
[dbo].[ORCT] T0 INNER JOIN RCT2 T1 ON T0.[DocEntry] = T1.[DocNum]
LEFT JOIN ODPI T3 ON T1. [DocEntry] = T3. [DocEntry] AND T1.[InvType] = T3.ObjType
LEFT JOIN OINV T4 ON T1. [DocEntry] = T4. [DocEntry] AND T1.[InvType] = T4.ObjType
LEFT JOIN OHEM T5 ON T3.[OwnerCode] = T5.[empID]
LEFT JOIN OHEM T6 ON T4.[OwnerCode] = T6.[empID]
LEFT JOIN OUSR T7 ON T5.[UserId] = T7.[USERID]
LEFT JOIN OUSR T8 ON T6.[UserId] = T8.[USERID]
LEFT JOIN ECM2 T9 ON T4.[DocEntry] = T9.[SrcObjAbs]
WHERE
T0.[DocDate] BETWEEN '2019/03/07' AND '2019/03/27' AND
(T3.[ObjType] IS NOT NULL OR T4.[ObjType] IS NOT NULL)