I would like to get all sales orders where the material number is ABCD. I would do this with an EXISTS in OpenSQL:
SELECT * FROM VBAK
INTO TABLE @DATA(lt_target)
WHERE EXISTS ( SELECT vbeln FROM VBAP
WHERE vbeln = vbak~vbeln
AND matnr = 'ABCD' ).
However, EXIST is not allowed in CDS views. How can I work around this limitation?
SELECT DISTINCTcan do the job to not repeat VBAK lines for each joined VBAP line, no idea whether it's optimized correctly or not behind.