Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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:
*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.
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' ) )
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
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' ) )