Hola, espero que todos se encuentren muy bien, quisiera hacer una pregunta sobre el generador de consultas de SAP, es posible realizar subconsultas dentro del generador ? ya que tengo una subconsulta que me está arrojando error, y no me logra especificar el por qué, la consulta es la siguiente:
SELECT
T0."CardCode" AS "CodigoCliente",
T3."CardName" AS "Cliente",
T4."U_GVS_Subzona" AS "Subzona",
T5."Name" AS "Vendedor Asignado",
T6."Name" AS "Municipio",
T6."U_NomDepartamento" AS "Departamento",
'Factura' AS "Tipo Documento",
T0."DocNum" AS "Número Factura",
T0."DocDate" AS "Fecha Factura",
DAYOFMONTH(T0."DocDate") AS "Día Factura",
MONTH(T0."DocDate") AS "Mes Factura",
YEAR(T0."DocDate") AS "Año Factura",
T7."Code" AS "Semana Factura",
T0."DocDueDate" AS "Vencimiento Factura",
DAYOFMONTH(T0."DocDueDate") AS "Día Vencimiento",
MONTH(T0."DocDueDate") AS "Mes Vencimiento",
YEAR(T0."DocDueDate") AS "Año Vencimiento",
T10."Code" AS "Semana Factura",
T8."Name" AS "Perfil",
T4."U_GVS_Frecuencia" AS "Frecuencia",
T4."U_GVS_Ruta" AS "Ruta",
T9."PymntGroup" AS "Plazo",
T3."CreditLine" AS "Cupo",
T0."DocTotal" AS "Total Factura",
null AS "NUM_RECONCILIACION",
T0."PaidToDate" AS "Valor Pago",
null AS "Fecha Reconciliación",
**(SELECT MAX(TT1."ReconDate") FROM ITR1 TT0 **
**INNER JOIN OITR TT1 ON TT1."ReconNum" = TT0."ReconNum"**
**WHERE TT0."TransId" = T0."TransId" AND TT0."IsCredit" = 'D' AND TT0."Account" = '13050501')** AS "Fecha Ultimo Pago"
FROM OINV T0
INNER JOIN OCRD T3 ON T3."CardCode" = T0."CardCode"
LEFT JOIN CRD1 T4 ON T4."CardCode" = T0."CardCode" AND T4."Address" = T0."ShipToCode" AND T4."AdresType" = 'S'
LEFT JOIN "@GVS_EMPLEADOS" T5 ON T5."Code" = T4."U_GVS_EmpVta"
LEFT JOIN "@HBT_MUNICIPIO" T6 ON T6."Code" = T4."U_HBT_MunMed"
LEFT JOIN "@GVS_SEMANAS" T7 ON T0."DocDate" BETWEEN T7."U_GVS_Desde" AND T7."U_GVS_Hasta"
LEFT JOIN "@GVS_PERFIL" T8 ON T8."Code"=T3."U_GVS_PerfClie"
INNER JOIN OCTG T9 ON T9."GroupNum" = T3."GroupNum"
LEFT JOIN "@GVS_SEMANAS" T10 ON T0."DocDueDate" BETWEEN T10."U_GVS_Desde" AND T10."U_GVS_Hasta"
WHERE T0."DocDate" BETWEEN '20210101' AND '20210131'
AND T0."Series" IN (144,4)
Lo que aparece con ** es la subconsulta.
Si pruebo este query en HANA directamente, sí me funciona, pero al pasarla al query manager da error, si quito la subconsulta, se ejecuta correctamente.
Agradezco si a alguien le pasa lo mismo y lo haya podido solucionar, me pueda dar su opinión.