0

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?

2
  • 2
    How does an inner join between VBAK/VBAP and selecting fields from VBAP is different to above query. Sample CDS code as below. define view entity zms_vbak_vbap as select from vbak join vbap on vbak.vbeln = vbap.vbeln { vbap fields } where matnr = 'ABCD' Commented May 10 at 0:05
  • 2
    SELECT DISTINCT can do the job to not repeat VBAK lines for each joined VBAP line, no idea whether it's optimized correctly or not behind. Commented May 10 at 14:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.