Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
atsushi_saijo
Creator II
Creator II

SAP Connector (6.x.x = latest) SubSelect does not support IN condition

Hi Gurus, there is an esoteric phenomena in SAP Connector. (latest version, 6.x.x).

Whenever we use condition 'IN', OpenSQL query fails.

It it observed that:

  1. SUBSELECT query does not support any WHERE condition except one condition of IN,
  2. SELECT in WHERE statement does not support IN (). It always must be EQ, NE, GT etc. 

*This forces developer to code loop(s) in the conditions. But perhaps most developers would use SUBSELECT to BSEG and KONV only. Would you advise how you have workaround on this?

[This statement passes Netweaver, but KSCHL EQ 'ZAAD' is ignored]

SQL SUBSELECT KNUMV KPOSN KSCHL KAWRT KBETR KPEIN WAERS KWERT

  FROM KONV WHERE

  KNUMV IN (SELECT KNUMV FROM VBRK

  WHERE FKDAT EQ '20170105'

  AND VTWEG NE '10'

  AND BUKRS EQ 'ZADV'

  )

  AND KSCHL EQ 'ZAAD'

  ;

[Does not work: note 2 conditions exists in IN]

SQL SUBSELECT KNUMV KPOSN KSCHL KAWRT KBETR KPEIN WAERS KWERT

  FROM KONV WHERE

  KNUMV IN (SELECT KNUMV FROM VBRK

  WHERE FKDAT EQ '20170105'

  AND VTWEG NE '10'

  AND BUKRS IN ('ZADV','ZADQ')

  )

  AND KSCHL IN ('ZAAD','ZAAC')

;

This query works: the single statement query within SubSelect

SELECT KNUMV FROM VBRK

  WHERE FKDAT EQ '20170105'

  AND VTWEG NE '10'

  AND BUKRS IN ('ZADV','ZADQ')

So it means we would need to use SUBSELECT always in a loop, where we execute it one by one: e.g. for entity ZADV, ZADQ, then for cost type ZAAD then ZAAC...... etc.

That is fine as well to control segmented dataset bits by bits, but I wonder if it is ABAP specification or actually bug?

I should appreciate for your feedback in advance.

1 Solution

Accepted Solutions
Hakan_Ronningberg

Since IN is not supported in the sub select you can write like this instead:

SQL SUBSELECT KNUMV KPOSN KSCHL KAWRT KBETR KPEIN WAERS KWERT

  FROM KONV WHERE

  KNUMV IN (SELECT KNUMV FROM VBRK

  WHERE FKDAT EQ '20170105'

  AND VTWEG NE '10'

  AND ( BUKRS EQ 'ZADV' OR BUKRS EQ 'ZADQ' ) )

View solution in original post

2 Replies
Hakan_Ronningberg

Hi Atsushi,

The short answer is that is is working as designed.


The SUBSELECT functionality was developed by Qlik as an addition to the standard SAP OPEN SQL. It makes it possible to do sub selects (like JOINS) of cluster tables, which is not possible in the standard SAP OPEN SQL. It does not support everything that is available in the SAP OPEN SQL. So for the moment it is not possible to use 'IN' conditions is the SELECT of the sub table. Neither it is possible to use AND in the the SELECT of the main table.

Here is a link to the online help where the SUBSELECT is described:

SQL SUBSELECT syntax ‒ Qlik Connectors

Best regards,

Hakan

Hakan_Ronningberg

Since IN is not supported in the sub select you can write like this instead:

SQL SUBSELECT KNUMV KPOSN KSCHL KAWRT KBETR KPEIN WAERS KWERT

  FROM KONV WHERE

  KNUMV IN (SELECT KNUMV FROM VBRK

  WHERE FKDAT EQ '20170105'

  AND VTWEG NE '10'

  AND ( BUKRS EQ 'ZADV' OR BUKRS EQ 'ZADQ' ) )