Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Ayuda con filtros en Query

Buenas tardes, estoy atorado al tratar de generar un filtro que me permita seleccionar cualquier opción de los valores del campo T2.[ItmsGrpNam] y con base a ello me arroje el resultado de la consulta, "en texto rojo especifico en donde se encuentra el error, si quito esto del código el query funciona bien" me pueden ayudar por favor?

SELECT ItemCode, Dscription, ItmsGrpNam, FirmName, U_GRUPO, U_LINEA,  SUM(Quantity) AS 'Qty Solicitada',SUM(DelivrdQty) AS 'Qty Suministrada',SUM(OpenQty) AS 'Qty Pendiente de entrega',U_PRESENTA

FROM (

SELECT T0.[ItemCode], T0.[Dscription], T2.[ItmsGrpNam], T3.[FirmName], T1.[U_GRUPO], T1.[U_LINEA],  T0.[Quantity], T0.[DelivrdQty] , T0.[OpenQty],T1.[U_PRESENTA]

FROM RDR1 T0 

INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode

INNER JOIN OITB T2 ON T1.ItmsGrpCod = T2.ItmsGrpCod

INNER JOIN OMRC T3 ON T1.FirmCode = T3.FirmCode

WHERE T0.[Openqty] >0 and T0.[WhsCode] = 1 and T2.[ItmsGrpNam] = [0%]) as a

GROUP BY ItemCode, Dscription, ItmsGrpNam, FirmName, U_GRUPO, U_LINEA, U_PRESENTA

order by ItmsGrpNam asc, FirmName asc, U_GRUPO asc , U_LINEA asc, ItemCode asc

Former Member
Former Member replied

Carlos, no muestras el mensaje de error como para darnos una idea de qué pudiera estar sucediendo. Intenta con alguno de los 2 siguientes queries que te propongo esperando alguno te funcione para lo que buscas:

/* Opción 1 */

SELECT T0.[ItemCode], T0.[Dscription], T2.[ItmsGrpNam], T3.[FirmName]

  , T1.[U_GRUPO], T1.[U_LINEA],T1.[U_PRESENTA]

  ,  SUM(T0.[Quantity]) 'Qty Solicitada', SUM(T0.[DelivrdQty]) 'Qty Sumistrada' , SUM(T0.[OpenQty]) 'Qty Pendiente de entrega'

FROM RDR1 T0

  INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode

  INNER JOIN OITB T2 ON T1.ItmsGrpCod = T2.ItmsGrpCod

  INNER JOIN OMRC T3 ON T1.FirmCode = T3.FirmCode

WHERE T0.[Openqty] >0 and T0.[WhsCode] = 1 and T2.[ItmsGrpNam] = [%0]

GROUP BY T0.ItemCode, Dscription, ItmsGrpNam, FirmName, U_GRUPO, U_LINEA, U_PRESENTA

order by ItmsGrpNam asc, FirmName asc, U_GRUPO asc , U_LINEA asc, T0.ItemCode asc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

/* Opción 2 */

SELECT T0.[ItemCode], T0.[Dscription], T2.[ItmsGrpNam], T3.[FirmName]

  , T1.[U_GRUPO], T1.[U_LINEA],T1.[U_PRESENTA]

  ,  SUM(T0.[Quantity]) 'Qty Solicitada', SUM(T0.[DelivrdQty]) 'Qty Sumistrada' , SUM(T0.[OpenQty]) 'Qty Pendiente de entrega'

FROM RDR1 T0

  INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode

  INNER JOIN OITB T2 ON T1.ItmsGrpCod = T2.ItmsGrpCod

  INNER JOIN OMRC T3 ON T1.FirmCode = T3.FirmCode

WHERE T0.[Openqty] >0 and T0.[WhsCode] = 1 and T2.[ItmsGrpNam] = '[%0]'

GROUP BY T0.ItemCode, Dscription, ItmsGrpNam, FirmName, U_GRUPO, U_LINEA, U_PRESENTA

order by ItmsGrpNam asc, FirmName asc, U_GRUPO asc , U_LINEA asc, T0.ItemCode asc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

Saludos y nos cuentas cómo te fue,

JC.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question