cancel
Showing results for 
Search instead for 
Did you mean: 

Error in query but can't identify where

Former Member
0 Kudos

Hello, i'm trying to make a query. This is my query:

SELECT

  T0."DocNum",

  T2."SlpName",

  T0."DocDate", 

  T0."CardName",

  ( 

  T0."VatSum" + T0."TotalExpns"

  + COALESCE( ( SELECT SUM(T4."LineTotal" ) FROM INV1 T4 WHERE ( T0."DocEntry" = T4."DocEntry" ) ),0)

  - T0."DiscSum" 

  ) AS DOCUMENT_TOTAL,

  ( 

  T0."VatSum" + T0."TotalExpns"

  + COALESCE( ( SELECT SUM( T1."LineTotal" ) FROM INV1 T1 WHERE ( T0."DocEntry" = T1."DocEntry" ) ) ,0) 

  - COALESCE( ( SELECT SUM( T3."DrawnSum" ) FROM INV9 T3 WHERE ( T0."DocEntry" = T3."DocEntry" ) AND ( T3."ObjType" = 203 ) ) ,0) 

  - T0."DiscSum" - T0."PaidToDate" 

  ) AS BALANCE_DUE,

  T0."GrosProfit"

FROM 

  OINV T0 

  INNER JOIN OSLP T2 ON (T0."SlpCode" = T2."SlpCode")

WHERE 

     (T0."DocDate" <= [%DocDate1] OR [%DocDate1] = '') 

  AND (T0."DocDate" >= [%DocDate2] OR [%DocDate2] = '') 

  AND (T2."SlpName" <= [%SlpName1] OR [%SlpName1] = '') 

  AND (T2."SlpName" >= [%SlpName2] OR [%SlpName2] = '') 

ORDER BY 

  T2."SlpName" ASC, 

  T0."DocDate" DESC

When i run the query (without the WHERE section) on HANA STUDIO it works fine.

When i go to SAP Query Manager and try to run it i have these scenarios:

1 - The query doesn't run.

2 - If i remove only the "WHERE" section, it works.

3 - If i remove only the "BALANCE DUE" and "DOCUMENT TOTAL" sections, it works (even with the "WHERE" section).

I don't know what to do to solve my problem.

Any idea?

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member185132
Active Contributor
0 Kudos

Please describe your data model with the DDL for the tables and some sample data.

Also describe what you are trying to achieve and what the problem is. For instance, saying the "query doesn't run" is not really helpful because we don't know what error (if any) is thrown by the system.