12-11-2023 11:54 AM
Hello, I have a problem. I want to write a SELECT query. In this query, I have data for LIKP. When I use LIKP-VERUR EQ MATDOC-XBLNR, I want the data not to come entirely if this data exists in the MATDOC for that specific row. Essentially, I need a structure that works in the exact opposite way of an inner join.
Previously, I connected with LEFT OUTER and then deleted the ones where the key field of MATDOC is filled. It worked, but I am experiencing performance issues because there is a lot of data. In my research, I think it can be solved by adding an additional SELECT within the WHERE condition, but I couldn't manage to do it.
SELECT likp~vbeln, likp~verur
FROM likp
LEFT OUTER JOIN matdoc AS mt ON mt~xblnr EQ likp~verur
INTO TABLE @DATA(lt_items)
Where likp~vbeln EQ @p_vbeln.
DELETE lt_items WHERE key1 IS NOT INITIAL.
12-11-2023 12:22 PM
Did you try a subquery (in where condition) such as
SELECT likp~vbeln, likp~verur
FROM likp
INTO TABLE @DATA(lt_items)
WHERE NOT EXISTS( SELECT * FROM MATDOC WHERE xblnr EQ likp~verur ).
You could also try to use operator EXCEPT (but shouldn't give better performance?)
12-11-2023 12:22 PM
Did you try a subquery (in where condition) such as
SELECT likp~vbeln, likp~verur
FROM likp
INTO TABLE @DATA(lt_items)
WHERE NOT EXISTS( SELECT * FROM MATDOC WHERE xblnr EQ likp~verur ).
You could also try to use operator EXCEPT (but shouldn't give better performance?)
12-11-2023 12:40 PM