Skip to Content
avatar image
Former Member

Problema con parametro y subqueries

Hola que tal,

Tengo una consulta que me da problemas con unos parametros de fecha, cuando quito los parametros me funciona perfecto, y también cuando dejo los parametros y quito los subqueries funciona bien; pero cuando quiero dejar tanto los parametros como los subqueries que es como yo quiero que funcione, me marca error y como SAP no es muy explícito con sus errores esperaba que alguno de ustedes pudiera ayudarme un poco, les dejo la consulta:

SELECT

          T0.U_PORTE  [Carta Porte],

          T0.U_NOMTRAB [Nombre Trab],

          T0.DocDate,

          T0.U_TRACT [Tractor],

          T0.U_PLAT [Plataforma],

          T0.U_LWB [Low Boy],

          T0.U_TIPOMAT  [Tipo de Material],

          T0.U_NTPESO  [Tons],

          T0.U_ORIGEN  [Origen,

          T0.U_DEST  [Destino],

          T0.U_PISTA  [Pista],

          T0.U_GUIA  [Guia],

          T0.DocCur  [Moneda],

          (SELECT DISTINCT SUM(LineTotal) FROM RDR1 A  WHERE ItemCode = 'flete' AND A.DocEntry = T0.DocEntry) [Flete],

          (SELECT DISTINCT SUM(LineTotal) FROM RDR1 A  WHERE ItemCode = 'maniobras' AND A.DocEntry = T0.DocEntry) [Maniobras],

          (T0.DocTotal - T0.VatSum) Subtotal,

          T0.VatSum IVA,

          ((SELECT DISTINCT SUM(LineTotal) FROM RDR1 A  WHERE ItemCode = 'flete' AND A.DocEntry = T0.DocEntry) * 0.04) [Retencion],

          T0.DocTotal Total,

          T0.U_ALM [OF de COB],

          T0.U_REMIT Remitente,

          T0.U_DESTEMPRESA Destinat,

          T0.U_NTFECHA [Salida],

          T0.U_NOTHRASAL [Hra Salida],

          T0.U_NTNUM [Vale Desp],

          T0.U_VALE [Gastos de Viaje],

          T0.U_PREST Prestamos,

          T0.U_MANIOB Maniobras,

          T0.U_AUTOP Autopista,

          T0.U_TOTALGTS [Total de Gastos],

          T0.U_VALEDIES [Vale Disel],

          T0.U_NOTCOMSAL [Disel/Lts],

          T0.U_NOTRENDIM [Km/Rend],

          T0.U_Lleno Lleno

FROM

          ORDR T0

WHERE

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

Muchas gracias de antemano, saludos!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Aug 22, 2012 at 10:29 PM

    Buenas

    Pruebalo así

    SELECT          T0.U_PORTE AS [Carta Porte],          T0.U_NOMTRAB AS [Nombre Trab],          T0.DocDate,          T0.U_TRACT AS [Tractor],          T0.U_PLAT AS [Plataforma],          T0.U_LWB AS [Low Boy],          T0.U_TIPOMAT AS  [Tipo de Material],          T0.U_NTPESO AS  [Tons],          T0.U_ORIGEN AS [Origen,          T0.U_DEST AS [Destino],          T0.U_PISTA AS [Pista],          T0.U_GUIA AS [Guia],          T0.DocCur AS [Moneda],          (SELECT DISTINCT SUM(LineTotal) FROM [dbo].[RDR1] A  WHERE ItemCode = 'flete' AND A.DocEntry = T0.DocEntry) AS [Flete],          (SELECT DISTINCT SUM(LineTotal) FROM [dbo].[RDR1] A  WHERE ItemCode = 'maniobras' AND A.DocEntry = T0.DocEntry) AS [Maniobras],          (T0.DocTotal - T0.VatSum) AS Subtotal,          T0.VatSum AS IVA,          ((SELECT DISTINCT SUM(LineTotal) FROM [dbo].[RDR1] A  WHERE ItemCode = 'flete' AND A.DocEntry = T0.DocEntry) * 0.04) AS [Retencion],          T0.DocTotal AS Total,          T0.U_ALM AS [OF de COB],          T0.U_REMIT AS Remitente,          T0.U_DESTEMPRESA AS Destinat,          T0.U_NTFECHA AS [Salida],          T0.U_NOTHRASAL AS [Hra Salida],          T0.U_NTNUM AS [Vale Desp],          T0.U_VALE AS [Gastos de Viaje],          T0.U_PREST AS Prestamos,          T0.U_MANIOB AS Maniobras,          T0.U_AUTOP AS Autopista,          T0.U_TOTALGTS AS [Total de Gastos],          T0.U_VALEDIES AS [Vale Disel],          T0.U_NOTCOMSAL AS [Disel/Lts],          T0.U_NOTRENDIM AS [Km/Rend],          T0.U_Lleno AS LlenoFROM          [dbo].[ORDR] T0WHERE          T0.DocDate >= '[%0]' AND T0.DocDate <= '[%1]'

    Saludos

    Felipe

    Add comment
    10|10000 characters needed characters exceeded